/* A packrat parser generated by PackCC 1.5.1 */

/* THIS PARSER SOURCE CODE IS GNU GPL FREE SOFTWARE VERSION 3+ */
#ifdef _MSC_VER
#error "not supported this is for use with GNU/Linux"
#undef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif /* _MSC_VER */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>		/* should have strnlen() */

/* #ifndef _MSC_VER */
					     /* #if defined __GNUC__ && defined _WIN32 *//* MinGW */
/* #ifndef PCC_USE_SYSTEM_STRNLEN */
/* #define strnlen(str, maxlen) pcc_strnlen(str, maxlen) */
/* static size_t pacc_strnlen_(const char *str, size_t maxlen) { */
/*    size_t i; */
/*    for (i = 0; i < maxlen && str[i]; i++); */
/*    return i; */
/* } */
	     /* #endif *//* !PCC_USE_SYSTEM_STRNLEN */
	     /* #endif *//* defined __GNUC__ && defined _WIN32 */
	     /* #endif *//* !_MSC_VER */

#define PCC_DBG_EVALUATE 0
#define PCC_DBG_MATCH    1
#define PCC_DBG_NOMATCH  2

#include "gml.h"

/* some setting in packcc code */
#define BUFFER_INIT_SIZE 256*2
#define ARRAY_INIT_SIZE 2*2

#include <stdio.h>
#include <string.h>

#include "splay-tree.h"
#include "main.h"
#include "dpmem.h"
#include "hier.h"

/* internal gml data */
struct gmlnd {
    char *id;			/* uniq node id number as string */
    long idlong;		/* uniq node id number */
    char *label;		/* optional node label */
};

struct gmled {
    int num;			/* uniq edge number */
    char *source;		/* source node */
    int idsource;		/* source id number */
    char *target;		/* target node */
    int idtarget;		/* target id number */
    char *label;		/* optional label */
};

/* stream to parse */
static FILE *gmlstream = NULL;

/* debug on/off */
static int showdebug = 0;

/* error status */
static int status = 0;

/* parsed node data */
static splay_tree gmln = (splay_tree) 0;

/* parsed edge data */
static splay_tree gmle = (splay_tree) 0;

/* edge counter */
static int ecount = 0;

/* last parsed number */
static char *lastnum = NULL;

/* last parsed number */
static char *lastfpnum = NULL;

/* last id string */
static char *lastid = NULL;

/* last pair id string */
static char *lastpairid = NULL;

/* last string */
static char *laststring = NULL;

/* type of data parsed */
static int gtype = 0;

/* type of pair data */
static int pairmode = 0;

/* current node id */
static char *cur_node_id = NULL;

/* current node label */
static char *cur_node_label = NULL;

/* current edge data */
static char *cur_edge_source = NULL;
static char *cur_edge_target = NULL;
static char *cur_edge_label = NULL;

/* getchar() is same as getc(stdin) pcc_auxil_t auxil
 * #define PCC_GETCHAR(auxil) getchar()
 */
#define PCC_GETCHAR(auxil) getc(stdin)
#define PCC_BUFFERSIZE 1024*128

#define PCC_ERROR(auxil) \
    do { fprintf(stdout, "PCC_ERROR(auxil) says Syntax error\n"); status = 1; } while (0)

static const char *dbg_str[] = { "Evaluating rule", "Matched rule", "Abandoning rule" };

#define PCC_DEBUG(event, rule, level, pos, buffer, length) \
    if (showdebug) fprintf(stdout, "%*s%s %s @%d [%.*s]\n", (int)(level * 2), "", dbg_str[event], rule, (int)pos, (int)length,  buffer); fflush(stdout)

/* forward declarations */

/* init parser */
static void init00(void);

/* switch between node[], edge[] etc. */
static void switcher(void);

/* add complete node/edge data */
static void adder(void);

/* handle a pair */
static void dopair(void);

/* copy data from parser to layouter */
static void copyin(void);

/* customized strdup() or use uniqstr() */
static char *gmlstrdup(const char *s);

#ifndef PCC_BUFFERSIZE
#define PCC_BUFFERSIZE 256
#endif /* !PCC_BUFFERSIZE */

#ifndef PCC_ARRAYSIZE
#define PCC_ARRAYSIZE 2
#endif /* !PCC_ARRAYSIZE */

#define VOID_VALUE (~(size_t)0)

typedef enum pcc_bool_tag {
    PCC_FALSE = 0,
    PCC_TRUE
} pcc_bool_t;

typedef struct pcc_char_array_tag {
    char *buf;
    size_t max;
    size_t len;
} pcc_char_array_t;

typedef struct pcc_range_tag {
    size_t start;
    size_t end;
} pcc_range_t;

typedef int pcc_value_t;

typedef void *pcc_auxil_t;

typedef struct pcc_value_table_tag {
    pcc_value_t *buf;
    size_t max;
    size_t len;
} pcc_value_table_t;

typedef struct pcc_value_refer_table_tag {
    pcc_value_t **buf;
    size_t max;
    size_t len;
} pcc_value_refer_table_t;

typedef struct pcc_capture_tag {
    pcc_range_t range;
    char *string;		/* mutable */
} pcc_capture_t;

typedef struct pcc_capture_table_tag {
    pcc_capture_t *buf;
    size_t max;
    size_t len;
} pcc_capture_table_t;

typedef struct pcc_capture_const_table_tag {
    const pcc_capture_t **buf;
    size_t max;
    size_t len;
} pcc_capture_const_table_t;

typedef struct pcc_thunk_tag pcc_thunk_t;
typedef struct pcc_thunk_array_tag pcc_thunk_array_t;

typedef void (*pcc_action_t)(gml_context_t *, pcc_thunk_t *, pcc_value_t *);

typedef enum pcc_thunk_type_tag {
    PCC_THUNK_LEAF,
    PCC_THUNK_NODE
} pcc_thunk_type_t;

typedef struct pcc_thunk_leaf_tag {
    pcc_value_refer_table_t values;
    pcc_capture_const_table_t capts;
    pcc_capture_t capt0;
    pcc_action_t action;
} pcc_thunk_leaf_t;

typedef struct pcc_thunk_node_tag {
    const pcc_thunk_array_t *thunks;	/* just a reference */
    pcc_value_t *value;		/* just a reference */
} pcc_thunk_node_t;

typedef union pcc_thunk_data_tag {
    pcc_thunk_leaf_t leaf;
    pcc_thunk_node_t node;
} pcc_thunk_data_t;

struct pcc_thunk_tag {
    pcc_thunk_type_t type;
    pcc_thunk_data_t data;
};

struct pcc_thunk_array_tag {
    pcc_thunk_t **buf;
    size_t max;
    size_t len;
};

typedef struct pcc_thunk_chunk_tag {
    pcc_value_table_t values;
    pcc_capture_table_t capts;
    pcc_thunk_array_t thunks;
    size_t pos;			/* the starting position in the character buffer */
} pcc_thunk_chunk_t;

typedef struct pcc_lr_entry_tag pcc_lr_entry_t;

typedef enum pcc_lr_answer_type_tag {
    PCC_LR_ANSWER_LR,
    PCC_LR_ANSWER_CHUNK
} pcc_lr_answer_type_t;

typedef union pcc_lr_answer_data_tag {
    pcc_lr_entry_t *lr;
    pcc_thunk_chunk_t *chunk;
} pcc_lr_answer_data_t;

typedef struct pcc_lr_answer_tag pcc_lr_answer_t;

struct pcc_lr_answer_tag {
    pcc_lr_answer_type_t type;
    pcc_lr_answer_data_t data;
    size_t pos;			/* the absolute position in the input */
    pcc_lr_answer_t *hold;
};

typedef pcc_thunk_chunk_t *(*pcc_rule_t)(gml_context_t *);

typedef struct pcc_rule_set_tag {
    pcc_rule_t *buf;
    size_t max;
    size_t len;
} pcc_rule_set_t;

typedef struct pcc_lr_head_tag pcc_lr_head_t;

struct pcc_lr_head_tag {
    pcc_rule_t rule;
    pcc_rule_set_t invol;
    pcc_rule_set_t eval;
    pcc_lr_head_t *hold;
};

typedef struct pcc_lr_memo_tag {
    pcc_rule_t rule;
    pcc_lr_answer_t *answer;
} pcc_lr_memo_t;

typedef struct pcc_lr_memo_map_tag {
    pcc_lr_memo_t *buf;
    size_t max;
    size_t len;
} pcc_lr_memo_map_t;

typedef struct pcc_lr_table_entry_tag {
    pcc_lr_head_t *head;	/* just a reference */
    pcc_lr_memo_map_t memos;
    pcc_lr_answer_t *hold_a;
    pcc_lr_head_t *hold_h;
} pcc_lr_table_entry_t;

typedef struct pcc_lr_table_tag {
    pcc_lr_table_entry_t **buf;
    size_t max;
    size_t len;
} pcc_lr_table_t;

struct pcc_lr_entry_tag {
    pcc_rule_t rule;
    pcc_thunk_chunk_t *seed;	/* just a reference */
    pcc_lr_head_t *head;	/* just a reference */
};

typedef struct pcc_lr_stack_tag {
    pcc_lr_entry_t **buf;
    size_t max;
    size_t len;
} pcc_lr_stack_t;

struct gml_context_tag {
    size_t pos;			/* the position in the input of the first character currently buffered */
    size_t cur;			/* the current parsing position in the character buffer */
    size_t level;
    pcc_char_array_t buffer;
    pcc_lr_table_t lrtable;
    pcc_lr_stack_t lrstack;
    pcc_auxil_t auxil;
};

#ifndef PCC_ERROR
#define PCC_ERROR(auxil) pcc_error()
static void pcc_error(void)
{
    fprintf(stderr, "Syntax error\n");
    exit(1);
}
#endif /* !PCC_ERROR */

#ifndef PCC_GETCHAR
#define PCC_GETCHAR(auxil) getchar()
#endif /* !PCC_GETCHAR */

#ifndef PCC_MALLOC
#define PCC_MALLOC(auxil, size) pcc_malloc_e(size)
static void *pcc_malloc_e(size_t size)
{
    void *const p = calloc(1, size);

    if (p == NULL) {
	fprintf(stderr, "PCC_MALLOC Out of memory\n");
	exit(1);
    }
    return p;
}
#endif /* !PCC_MALLOC */

#ifndef PCC_REALLOC
#define PCC_REALLOC(auxil, ptr, size) pcc_realloc_e(ptr, size)
static void *pcc_realloc_e(void *ptr, size_t size)
{
    void *const p = realloc(ptr, size);
    if (p == NULL) {
	fprintf(stderr, "PCC_REALLOC Out of memory\n");
	exit(1);
    }
    return p;
}
#endif /* !PCC_REALLOC */

#ifndef PCC_FREE
#define PCC_FREE(auxil, ptr) do { if (auxil) {} if (ptr) { free(ptr); } } while (0);
#endif /* !PCC_FREE */

#ifndef PCC_DEBUG
#define PCC_DEBUG(event, rule, level, pos, buffer, length) ((void)0)
#endif /* !PCC_DEBUG */

static char *pcc_strndup_e(pcc_auxil_t auxil, const char *str, size_t len)
{
    const size_t m = strnlen(str, len);	/* prototype is in <string.h> */
    char *const s = (char *)PCC_MALLOC(auxil, m + 1);
    if (auxil) {
    }
    memmove(s, str, m);
    if (auxil) {
    }
    s[m] = '\0';
    return s;
}

static void pcc_char_array__init(pcc_auxil_t auxil, pcc_char_array_t * array, size_t max)
{
    array->len = 0;
    array->max = max;
    array->buf = (char *)PCC_MALLOC(auxil, array->max);
    if (auxil) {
    }
}

static void pcc_char_array__add(pcc_auxil_t auxil, pcc_char_array_t * array, char ch)
{
    if (auxil) {
    }
    if (array->max <= array->len) {
	const size_t n = array->len + 1;
	size_t m = array->max;
	if (m == 0)
	    m = 1;
	while (m < n && m != 0)
	    m <<= 1;
	if (m == 0)
	    m = n;
	array->buf = (char *)PCC_REALLOC(auxil, array->buf, m);
	if (auxil) {
	}
	array->max = m;
    }
    array->buf[array->len++] = ch;
}

static void pcc_char_array__term(pcc_auxil_t auxil, pcc_char_array_t * array)
{
    PCC_FREE(auxil, array->buf);
}

static void pcc_value_table__init(pcc_auxil_t auxil, pcc_value_table_t * table, size_t max)
{
    table->len = 0;
    table->max = max;
    table->buf = (pcc_value_t *) PCC_MALLOC(auxil, sizeof(pcc_value_t) * table->max);
    if (auxil) {
    }
}

static void pcc_value_table__resize(pcc_auxil_t auxil, pcc_value_table_t * table, size_t len)
{
    if (table->max < len) {
	size_t m = table->max;
	if (m == 0)
	    m = 1;
	while (m < len && m != 0)
	    m <<= 1;
	if (m == 0)
	    m = len;
	table->buf = (pcc_value_t *) PCC_REALLOC(auxil, table->buf, sizeof(pcc_value_t) * m);
	if (auxil) {
	}
	table->max = m;
    }
    table->len = len;
}

static void pcc_value_table__term(pcc_auxil_t auxil, pcc_value_table_t * table)
{
    PCC_FREE(auxil, table->buf);
}

static void pcc_value_refer_table__init(pcc_auxil_t auxil, pcc_value_refer_table_t * table, size_t max)
{
    table->len = 0;
    table->max = max;
    table->buf = (pcc_value_t **) PCC_MALLOC(auxil, sizeof(pcc_value_t *) * table->max);
    if (auxil) {
    }
}

static void pcc_value_refer_table__resize(pcc_auxil_t auxil, pcc_value_refer_table_t * table, size_t len)
{
    size_t i;
    if (table->max < len) {
	size_t m = table->max;
	if (m == 0)
	    m = 1;
	while (m < len && m != 0)
	    m <<= 1;
	if (m == 0)
	    m = len;
	table->buf = (pcc_value_t **) PCC_REALLOC(auxil, table->buf, sizeof(pcc_value_t *) * m);
	if (auxil) {
	}
	table->max = m;
    }
    for (i = table->len; i < len; i++)
	table->buf[i] = NULL;
    table->len = len;
}

static void pcc_value_refer_table__term(pcc_auxil_t auxil, pcc_value_refer_table_t * table)
{
    if (auxil) {
    }
    PCC_FREE(auxil, table->buf);
}

static void pcc_capture_table__init(pcc_auxil_t auxil, pcc_capture_table_t * table, size_t max)
{
    table->len = 0;
    table->max = max;
    table->buf = (pcc_capture_t *) PCC_MALLOC(auxil, sizeof(pcc_capture_t) * table->max);
    if (auxil) {
    }
}

static void pcc_capture_table__resize(pcc_auxil_t auxil, pcc_capture_table_t * table, size_t len)
{
    size_t i;
    for (i = len; i < table->len; i++)
	PCC_FREE(auxil, table->buf[i].string);
    if (table->max < len) {
	size_t m = table->max;
	if (m == 0)
	    m = 1;
	while (m < len && m != 0)
	    m <<= 1;
	if (m == 0)
	    m = len;
	table->buf = (pcc_capture_t *) PCC_REALLOC(auxil, table->buf, sizeof(pcc_capture_t) * m);
	if (auxil) {
	}
	table->max = m;
    }
    for (i = table->len; i < len; i++) {
	table->buf[i].range.start = 0;
	table->buf[i].range.end = 0;
	table->buf[i].string = NULL;
    }
    table->len = len;
}

static void pcc_capture_table__term(pcc_auxil_t auxil, pcc_capture_table_t * table)
{
    if (auxil) {
    }
    while (table->len > 0) {
	table->len--;
	PCC_FREE(auxil, table->buf[table->len].string);
    }
    PCC_FREE(auxil, table->buf);
}

static void pcc_capture_const_table__init(pcc_auxil_t auxil, pcc_capture_const_table_t * table, size_t max)
{
    table->len = 0;
    table->max = max;
    table->buf = (const pcc_capture_t **)PCC_MALLOC(auxil, sizeof(const pcc_capture_t *) * table->max);
    if (auxil) {
    }
}

static void pcc_capture_const_table__resize(pcc_auxil_t auxil, pcc_capture_const_table_t * table, size_t len)
{
    if (auxil) {
    }
    size_t i;
    if (table->max < len) {
	size_t m = table->max;
	if (m == 0)
	    m = 1;
	while (m < len && m != 0)
	    m <<= 1;
	if (m == 0)
	    m = len;
	table->buf = (const pcc_capture_t **)PCC_REALLOC(auxil, (pcc_capture_t **) table->buf, sizeof(const pcc_capture_t *) * m);
	if (auxil) {
	}
	table->max = m;
    }
    for (i = table->len; i < len; i++)
	table->buf[i] = NULL;
    table->len = len;
}

static void pcc_capture_const_table__term(pcc_auxil_t auxil, pcc_capture_const_table_t * table)
{
    if (auxil) {
    }
    PCC_FREE(auxil, table->buf);
}

static pcc_thunk_t *pcc_thunk__create_leaf(pcc_auxil_t auxil, pcc_action_t action, size_t valuec, size_t captc)
{
    pcc_thunk_t *const thunk = (pcc_thunk_t *) PCC_MALLOC(auxil, sizeof(pcc_thunk_t));
    if (auxil) {
    }

    thunk->type = PCC_THUNK_LEAF;
    pcc_value_refer_table__init(auxil, &thunk->data.leaf.values, valuec);
    pcc_value_refer_table__resize(auxil, &thunk->data.leaf.values, valuec);
    pcc_capture_const_table__init(auxil, &thunk->data.leaf.capts, captc);
    pcc_capture_const_table__resize(auxil, &thunk->data.leaf.capts, captc);
    thunk->data.leaf.capt0.range.start = 0;
    thunk->data.leaf.capt0.range.end = 0;
    thunk->data.leaf.capt0.string = NULL;
    thunk->data.leaf.action = action;
    return thunk;
}

static pcc_thunk_t *pcc_thunk__create_node(pcc_auxil_t auxil, const pcc_thunk_array_t * thunks, pcc_value_t * value)
{
    if (auxil) {
    }
    pcc_thunk_t *const thunk = (pcc_thunk_t *) PCC_MALLOC(auxil, sizeof(pcc_thunk_t));
    if (auxil) {
    }
    thunk->type = PCC_THUNK_NODE;
    thunk->data.node.thunks = thunks;
    thunk->data.node.value = value;
    return thunk;
}

static void pcc_thunk__destroy(pcc_auxil_t auxil, pcc_thunk_t * thunk)
{
    if (thunk == NULL)
	return;
    switch (thunk->type) {
    case PCC_THUNK_LEAF:
	PCC_FREE(auxil, thunk->data.leaf.capt0.string);
	pcc_capture_const_table__term(auxil, &thunk->data.leaf.capts);
	pcc_value_refer_table__term(auxil, &thunk->data.leaf.values);
	break;
    case PCC_THUNK_NODE:
	break;
    default:			/* unknown */
	break;
    }
    PCC_FREE(auxil, thunk);
}

static void pcc_thunk_array__init(pcc_auxil_t auxil, pcc_thunk_array_t * array, size_t max)
{
    array->len = 0;
    array->max = max;
    array->buf = (pcc_thunk_t **) PCC_MALLOC(auxil, sizeof(pcc_thunk_t *) * array->max);
    if (auxil) {
    }
}

static void pcc_thunk_array__add(pcc_auxil_t auxil, pcc_thunk_array_t * array, pcc_thunk_t * thunk)
{
    if (auxil) {
    }
    if (array->max <= array->len) {
	const size_t n = array->len + 1;
	size_t m = array->max;
	if (m == 0)
	    m = 1;
	while (m < n && m != 0)
	    m <<= 1;
	if (m == 0)
	    m = n;
	array->buf = (pcc_thunk_t **) PCC_REALLOC(auxil, array->buf, sizeof(pcc_thunk_t *) * m);
	if (auxil) {
	}
	array->max = m;
    }
    array->buf[array->len++] = thunk;
}

static void pcc_thunk_array__revert(pcc_auxil_t auxil, pcc_thunk_array_t * array, size_t len)
{
    while (array->len > len) {
	array->len--;
	pcc_thunk__destroy(auxil, array->buf[array->len]);
    }
}

static void pcc_thunk_array__term(pcc_auxil_t auxil, pcc_thunk_array_t * array)
{
    while (array->len > 0) {
	array->len--;
	pcc_thunk__destroy(auxil, array->buf[array->len]);
    }
    PCC_FREE(auxil, array->buf);
}

static pcc_thunk_chunk_t *pcc_thunk_chunk__create(pcc_auxil_t auxil)
{
    pcc_thunk_chunk_t *const chunk = (pcc_thunk_chunk_t *) PCC_MALLOC(auxil, sizeof(pcc_thunk_chunk_t));
    if (auxil) {
    }
    pcc_value_table__init(auxil, &chunk->values, PCC_ARRAYSIZE);
    pcc_capture_table__init(auxil, &chunk->capts, PCC_ARRAYSIZE);
    pcc_thunk_array__init(auxil, &chunk->thunks, PCC_ARRAYSIZE);
    chunk->pos = 0;
    return chunk;
}

static void pcc_thunk_chunk__destroy(pcc_auxil_t auxil, pcc_thunk_chunk_t * chunk)
{
    if (chunk == NULL)
	return;
    pcc_thunk_array__term(auxil, &chunk->thunks);
    pcc_capture_table__term(auxil, &chunk->capts);
    pcc_value_table__term(auxil, &chunk->values);
    PCC_FREE(auxil, chunk);
}

static void pcc_rule_set__init(pcc_auxil_t auxil, pcc_rule_set_t * set, size_t max)
{
    if (auxil) {
    }
    set->len = 0;
    set->max = max;
    set->buf = (pcc_rule_t *) PCC_MALLOC(auxil, sizeof(pcc_rule_t) * set->max);
    if (auxil) {
    }
}

static size_t pcc_rule_set__index(pcc_auxil_t auxil, const pcc_rule_set_t * set, pcc_rule_t rule)
{
    if (auxil) {
    }
    size_t i;
    for (i = 0; i < set->len; i++) {
	if (set->buf[i] == rule)
	    return i;
    }
    return VOID_VALUE;
}

static pcc_bool_t pcc_rule_set__add(pcc_auxil_t auxil, pcc_rule_set_t * set, pcc_rule_t rule)
{
    const size_t i = pcc_rule_set__index(auxil, set, rule);
    if (i != VOID_VALUE)
	return PCC_FALSE;
    if (set->max <= set->len) {
	const size_t n = set->len + 1;
	size_t m = set->max;
	if (m == 0)
	    m = 1;
	while (m < n && m != 0)
	    m <<= 1;
	if (m == 0)
	    m = n;
	set->buf = (pcc_rule_t *) PCC_REALLOC(auxil, set->buf, sizeof(pcc_rule_t) * m);
	if (auxil) {
	}
	set->max = m;
    }
    set->buf[set->len++] = rule;
    return PCC_TRUE;
}

static pcc_bool_t pcc_rule_set__remove(pcc_auxil_t auxil, pcc_rule_set_t * set, pcc_rule_t rule)
{
    const size_t i = pcc_rule_set__index(auxil, set, rule);
    if (i == VOID_VALUE)
	return PCC_FALSE;
    memmove(set->buf + i, set->buf + (i + 1), sizeof(pcc_rule_t) * (set->len - (i + 1)));
    return PCC_TRUE;
}

static void pcc_rule_set__clear(pcc_auxil_t auxil, pcc_rule_set_t * set)
{
    if (auxil) {
    }
    set->len = 0;
}

static void pcc_rule_set__copy(pcc_auxil_t auxil, pcc_rule_set_t * set, const pcc_rule_set_t * src)
{
    size_t i;
    pcc_rule_set__clear(auxil, set);
    for (i = 0; i < src->len; i++) {
	pcc_rule_set__add(auxil, set, src->buf[i]);
    }
}

static void pcc_rule_set__term(pcc_auxil_t auxil, pcc_rule_set_t * set)
{
    if (auxil) {
    }
    PCC_FREE(auxil, set->buf);
}

static pcc_lr_head_t *pcc_lr_head__create(pcc_auxil_t auxil, pcc_rule_t rule)
{
    pcc_lr_head_t *const head = (pcc_lr_head_t *) PCC_MALLOC(auxil, sizeof(pcc_lr_head_t));
    if (auxil) {
    }
    head->rule = rule;
    pcc_rule_set__init(auxil, &head->invol, PCC_ARRAYSIZE);
    pcc_rule_set__init(auxil, &head->eval, PCC_ARRAYSIZE);
    head->hold = NULL;
    return head;
}

static void pcc_lr_head__destroy(pcc_auxil_t auxil, pcc_lr_head_t * head)
{
    if (head == NULL)
	return;
    pcc_lr_head__destroy(auxil, head->hold);
    pcc_rule_set__term(auxil, &head->eval);
    pcc_rule_set__term(auxil, &head->invol);
    PCC_FREE(auxil, head);
}

static void pcc_lr_entry__destroy(pcc_auxil_t auxil, pcc_lr_entry_t * lr);	/* prototype */

static pcc_lr_answer_t *pcc_lr_answer__create(pcc_auxil_t auxil, pcc_lr_answer_type_t type, size_t pos)
{
    if (auxil) {
    }
    pcc_lr_answer_t *answer = (pcc_lr_answer_t *) PCC_MALLOC(auxil, sizeof(pcc_lr_answer_t));
    if (auxil) {
    }
    answer->type = type;
    answer->pos = pos;
    answer->hold = NULL;
    switch (answer->type) {
    case PCC_LR_ANSWER_LR:
	answer->data.lr = NULL;
	break;
    case PCC_LR_ANSWER_CHUNK:
	answer->data.chunk = NULL;
	break;
    default:			/* unknown */
	PCC_FREE(auxil, answer);
	answer = NULL;
	break;
    }
    return answer;
}

static void pcc_lr_answer__set_chunk(pcc_auxil_t auxil, pcc_lr_answer_t * answer, pcc_thunk_chunk_t * chunk)
{
    pcc_lr_answer_t *const a = pcc_lr_answer__create(auxil, answer->type, answer->pos);
    switch (answer->type) {
    case PCC_LR_ANSWER_LR:
	a->data.lr = answer->data.lr;
	break;
    case PCC_LR_ANSWER_CHUNK:
	a->data.chunk = answer->data.chunk;
	break;
    default:			/* unknown */
	break;
    }
    a->hold = answer->hold;
    answer->hold = a;
    answer->type = PCC_LR_ANSWER_CHUNK;
    answer->data.chunk = chunk;
}

static void pcc_lr_answer__destroy(pcc_auxil_t auxil, pcc_lr_answer_t * answer)
{
    if (answer == NULL)
	return;
    pcc_lr_answer__destroy(auxil, answer->hold);
    switch (answer->type) {
    case PCC_LR_ANSWER_LR:
	pcc_lr_entry__destroy(auxil, answer->data.lr);
	break;
    case PCC_LR_ANSWER_CHUNK:
	pcc_thunk_chunk__destroy(auxil, answer->data.chunk);
	break;
    default:			/* unknown */
	break;
    }
    PCC_FREE(auxil, answer);
}

static void pcc_lr_memo_map__init(pcc_auxil_t auxil, pcc_lr_memo_map_t * map, size_t max)
{
    if (auxil) {
    }
    map->len = 0;
    map->max = max;
    map->buf = (pcc_lr_memo_t *) PCC_MALLOC(auxil, sizeof(pcc_lr_memo_t) * map->max);
    if (auxil) {
    }
}

static size_t pcc_lr_memo_map__index(pcc_auxil_t auxil, pcc_lr_memo_map_t * map, pcc_rule_t rule)
{
    if (auxil) {
    }
    size_t i;
    for (i = 0; i < map->len; i++) {
	if (map->buf[i].rule == rule)
	    return i;
    }
    return VOID_VALUE;
}

static void pcc_lr_memo_map__put(pcc_auxil_t auxil, pcc_lr_memo_map_t * map, pcc_rule_t rule, pcc_lr_answer_t * answer)
{
    const size_t i = pcc_lr_memo_map__index(auxil, map, rule);
    if (i != VOID_VALUE) {
	pcc_lr_answer__destroy(auxil, map->buf[i].answer);
	map->buf[i].answer = answer;
    } else {
	if (map->max <= map->len) {
	    const size_t n = map->len + 1;
	    size_t m = map->max;
	    if (m == 0)
		m = 1;
	    while (m < n && m != 0)
		m <<= 1;
	    if (m == 0)
		m = n;
	    map->buf = (pcc_lr_memo_t *) PCC_REALLOC(auxil, map->buf, sizeof(pcc_lr_memo_t) * m);
	    if (auxil) {
	    }
	    map->max = m;
	}
	map->buf[map->len].rule = rule;
	map->buf[map->len].answer = answer;
	map->len++;
    }
}

static pcc_lr_answer_t *pcc_lr_memo_map__get(pcc_auxil_t auxil, pcc_lr_memo_map_t * map, pcc_rule_t rule)
{
    const size_t i = pcc_lr_memo_map__index(auxil, map, rule);
    return (i != VOID_VALUE) ? map->buf[i].answer : NULL;
}

static void pcc_lr_memo_map__term(pcc_auxil_t auxil, pcc_lr_memo_map_t * map)
{
    while (map->len > 0) {
	map->len--;
	pcc_lr_answer__destroy(auxil, map->buf[map->len].answer);
    }
    PCC_FREE(auxil, map->buf);
}

static pcc_lr_table_entry_t *pcc_lr_table_entry__create(pcc_auxil_t auxil)
{
    pcc_lr_table_entry_t *const entry = (pcc_lr_table_entry_t *) PCC_MALLOC(auxil, sizeof(pcc_lr_table_entry_t));
    if (auxil) {
    }
    entry->head = NULL;
    pcc_lr_memo_map__init(auxil, &entry->memos, PCC_ARRAYSIZE);
    entry->hold_a = NULL;
    entry->hold_h = NULL;
    return entry;
}

static void pcc_lr_table_entry__destroy(pcc_auxil_t auxil, pcc_lr_table_entry_t * entry)
{
    if (auxil) {
    }
    if (entry == NULL)
	return;
    pcc_lr_head__destroy(auxil, entry->hold_h);
    pcc_lr_answer__destroy(auxil, entry->hold_a);
    pcc_lr_memo_map__term(auxil, &entry->memos);
    PCC_FREE(auxil, entry);
}

static void pcc_lr_table__init(pcc_auxil_t auxil, pcc_lr_table_t * table, size_t max)
{
    if (auxil) {
    }
    table->len = 0;
    table->max = max;
    table->buf = (pcc_lr_table_entry_t **) PCC_MALLOC(auxil, sizeof(pcc_lr_table_entry_t *) * table->max);
    if (auxil) {
    }
}

static void pcc_lr_table__resize(pcc_auxil_t auxil, pcc_lr_table_t * table, size_t len)
{
    size_t i;
    for (i = len; i < table->len; i++)
	pcc_lr_table_entry__destroy(auxil, table->buf[i]);
    if (table->max < len) {
	size_t m = table->max;
	if (m == 0)
	    m = 1;
	while (m < len && m != 0)
	    m <<= 1;
	if (m == 0)
	    m = len;
	table->buf = (pcc_lr_table_entry_t **) PCC_REALLOC(auxil, table->buf, sizeof(pcc_lr_table_entry_t *) * m);
	if (auxil) {
	}
	table->max = m;
    }
    for (i = table->len; i < len; i++)
	table->buf[i] = NULL;
    table->len = len;
}

static void pcc_lr_table__set_head(pcc_auxil_t auxil, pcc_lr_table_t * table, size_t index, pcc_lr_head_t * head)
{
    if (index >= table->len)
	pcc_lr_table__resize(auxil, table, index + 1);
    if (table->buf[index] == NULL)
	table->buf[index] = pcc_lr_table_entry__create(auxil);
    table->buf[index]->head = head;
}

static void pcc_lr_table__hold_head(pcc_auxil_t auxil, pcc_lr_table_t * table, size_t index, pcc_lr_head_t * head)
{
    if (index >= table->len)
	pcc_lr_table__resize(auxil, table, index + 1);
    if (table->buf[index] == NULL)
	table->buf[index] = pcc_lr_table_entry__create(auxil);
    head->hold = table->buf[index]->hold_h;
    table->buf[index]->hold_h = head;
}

static void pcc_lr_table__set_answer(pcc_auxil_t auxil, pcc_lr_table_t * table, size_t index, pcc_rule_t rule, pcc_lr_answer_t * answer)
{
    if (index >= table->len)
	pcc_lr_table__resize(auxil, table, index + 1);
    if (table->buf[index] == NULL)
	table->buf[index] = pcc_lr_table_entry__create(auxil);
    pcc_lr_memo_map__put(auxil, &table->buf[index]->memos, rule, answer);
}

static void pcc_lr_table__hold_answer(pcc_auxil_t auxil, pcc_lr_table_t * table, size_t index, pcc_lr_answer_t * answer)
{
    if (index >= table->len)
	pcc_lr_table__resize(auxil, table, index + 1);
    if (table->buf[index] == NULL)
	table->buf[index] = pcc_lr_table_entry__create(auxil);
    answer->hold = table->buf[index]->hold_a;
    table->buf[index]->hold_a = answer;
}

static pcc_lr_head_t *pcc_lr_table__get_head(pcc_auxil_t auxil, pcc_lr_table_t * table, size_t index)
{
    if (auxil) {
    }
    if (index >= table->len || table->buf[index] == NULL)
	return NULL;
    return table->buf[index]->head;
}

static pcc_lr_answer_t *pcc_lr_table__get_answer(pcc_auxil_t auxil, pcc_lr_table_t * table, size_t index, pcc_rule_t rule)
{
    if (auxil) {
    }
    if (index >= table->len || table->buf[index] == NULL)
	return NULL;
    return pcc_lr_memo_map__get(auxil, &table->buf[index]->memos, rule);
}

static void pcc_lr_table__shift(pcc_auxil_t auxil, pcc_lr_table_t * table, size_t count)
{
    size_t i;
    if (count > table->len)
	count = table->len;
    for (i = 0; i < count; i++)
	pcc_lr_table_entry__destroy(auxil, table->buf[i]);
    memmove(table->buf, table->buf + count, sizeof(pcc_lr_table_entry_t *) * (table->len - count));
    table->len -= count;
}

static void pcc_lr_table__term(pcc_auxil_t auxil, pcc_lr_table_t * table)
{
    while (table->len > 0) {
	table->len--;
	pcc_lr_table_entry__destroy(auxil, table->buf[table->len]);
    }
    PCC_FREE(auxil, table->buf);
}

static pcc_lr_entry_t *pcc_lr_entry__create(pcc_auxil_t auxil, pcc_rule_t rule)
{
    if (auxil) {
    }
    pcc_lr_entry_t *const lr = (pcc_lr_entry_t *) PCC_MALLOC(auxil, sizeof(pcc_lr_entry_t));
    if (auxil) {
    }
    lr->rule = rule;
    lr->seed = NULL;
    lr->head = NULL;
    return lr;
}

static void pcc_lr_entry__destroy(pcc_auxil_t auxil, pcc_lr_entry_t * lr)
{
    if (auxil) {
    }
    PCC_FREE(auxil, lr);
}

static void pcc_lr_stack__init(pcc_auxil_t auxil, pcc_lr_stack_t * stack, size_t max)
{
    if (auxil) {
    }
    stack->len = 0;
    stack->max = max;
    stack->buf = (pcc_lr_entry_t **) PCC_MALLOC(auxil, sizeof(pcc_lr_entry_t *) * stack->max);
    if (auxil) {
    }
}

static void pcc_lr_stack__push(pcc_auxil_t auxil, pcc_lr_stack_t * stack, pcc_lr_entry_t * lr)
{
    if (auxil) {
    }
    if (stack->max <= stack->len) {
	const size_t n = stack->len + 1;
	size_t m = stack->max;
	if (m == 0)
	    m = 1;
	while (m < n && m != 0)
	    m <<= 1;
	if (m == 0)
	    m = n;
	stack->buf = (pcc_lr_entry_t **) PCC_REALLOC(auxil, stack->buf, sizeof(pcc_lr_entry_t *) * m);
	if (auxil) {
	}
	stack->max = m;
    }
    stack->buf[stack->len++] = lr;
}

static pcc_lr_entry_t *pcc_lr_stack__pop(pcc_auxil_t auxil, pcc_lr_stack_t * stack)
{
    if (auxil) {
    }
    return stack->buf[--stack->len];
}

static void pcc_lr_stack__term(pcc_auxil_t auxil, pcc_lr_stack_t * stack)
{
    if (auxil) {
    }
    PCC_FREE(auxil, stack->buf);
}

static gml_context_t *pcc_context__create(pcc_auxil_t auxil)
{
    gml_context_t *const ctx = (gml_context_t *) PCC_MALLOC(auxil, sizeof(gml_context_t));
    if (auxil) {
    }
    ctx->pos = 0;
    ctx->cur = 0;
    ctx->level = 0;
    pcc_char_array__init(auxil, &ctx->buffer, PCC_BUFFERSIZE);
    pcc_lr_table__init(auxil, &ctx->lrtable, PCC_BUFFERSIZE);
    pcc_lr_stack__init(auxil, &ctx->lrstack, PCC_ARRAYSIZE);
    ctx->auxil = auxil;
    return ctx;
}

static void pcc_context__destroy(gml_context_t * ctx)
{
    if (ctx == NULL)
	return;
    pcc_lr_stack__term(ctx->auxil, &ctx->lrstack);
    pcc_lr_table__term(ctx->auxil, &ctx->lrtable);
    pcc_char_array__term(ctx->auxil, &ctx->buffer);
    PCC_FREE(ctx->auxil, ctx);
}

static size_t pcc_refill_buffer(gml_context_t * ctx, size_t num)
{
    if (ctx->buffer.len >= ctx->cur + num)
	return ctx->buffer.len - ctx->cur;
    while (ctx->buffer.len < ctx->cur + num) {
	const int c = PCC_GETCHAR(ctx->auxil);
	if (c == EOF)
	    break;
	pcc_char_array__add(ctx->auxil, &ctx->buffer, (char)c);
    }
    return ctx->buffer.len - ctx->cur;
}

static void pcc_commit_buffer(gml_context_t * ctx)
{
    memmove(ctx->buffer.buf, ctx->buffer.buf + ctx->cur, ctx->buffer.len - ctx->cur);
    ctx->buffer.len -= ctx->cur;
    ctx->pos += ctx->cur;
    pcc_lr_table__shift(ctx->auxil, &ctx->lrtable, ctx->cur);
    ctx->cur = 0;
}

static const char *pcc_get_capture_string(gml_context_t * ctx, const pcc_capture_t * capt)
{
    if (capt->string == NULL)
	((pcc_capture_t *) capt)->string = pcc_strndup_e(ctx->auxil, ctx->buffer.buf + capt->range.start, capt->range.end - capt->range.start);
    return capt->string;
}

static size_t pcc_get_char_as_utf32(gml_context_t * ctx, int *out)
{				/* with checking UTF-8 validity */
    int c, u;
    size_t n;
    if (pcc_refill_buffer(ctx, 1) < 1)
	return 0;
    c = (int)(unsigned char)ctx->buffer.buf[ctx->cur];
    n = (c < 0x80) ? 1 : ((c & 0xe0) == 0xc0) ? 2 : ((c & 0xf0) == 0xe0) ? 3 : ((c & 0xf8) == 0xf0) ? 4 : 0;
    if (n < 1)
	return 0;
    if (pcc_refill_buffer(ctx, n) < n)
	return 0;
    switch (n) {
    case 1:
	u = c;
	break;
    case 2:
	u = c & 0x1f;
	c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 1];
	if ((c & 0xc0) != 0x80)
	    return 0;
	u <<= 6;
	u |= c & 0x3f;
	if (u < 0x80)
	    return 0;
	break;
    case 3:
	u = c & 0x0f;
	c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 1];
	if ((c & 0xc0) != 0x80)
	    return 0;
	u <<= 6;
	u |= c & 0x3f;
	c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 2];
	if ((c & 0xc0) != 0x80)
	    return 0;
	u <<= 6;
	u |= c & 0x3f;
	if (u < 0x800)
	    return 0;
	break;
    case 4:
	u = c & 0x07;
	c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 1];
	if ((c & 0xc0) != 0x80)
	    return 0;
	u <<= 6;
	u |= c & 0x3f;
	c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 2];
	if ((c & 0xc0) != 0x80)
	    return 0;
	u <<= 6;
	u |= c & 0x3f;
	c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 3];
	if ((c & 0xc0) != 0x80)
	    return 0;
	u <<= 6;
	u |= c & 0x3f;
	if (u < 0x10000 || u > 0x10ffff)
	    return 0;
	break;
    default:
	return 0;
    }
    if (out)
	*out = u;
    return n;
}

static pcc_bool_t pcc_apply_rule(gml_context_t * ctx, pcc_rule_t rule, pcc_thunk_array_t * thunks, pcc_value_t * value)
{
    static pcc_value_t null;
    pcc_thunk_chunk_t *c = NULL;
    const size_t p = ctx->pos + ctx->cur;
    pcc_bool_t b = PCC_TRUE;
    pcc_lr_answer_t *a = pcc_lr_table__get_answer(ctx->auxil, &ctx->lrtable, p, rule);
    pcc_lr_head_t *h = pcc_lr_table__get_head(ctx->auxil, &ctx->lrtable, p);
    if (h != NULL) {
	if (a == NULL && rule != h->rule && pcc_rule_set__index(ctx->auxil, &h->invol, rule) == VOID_VALUE) {
	    b = PCC_FALSE;
	    c = NULL;
	} else if (pcc_rule_set__remove(ctx->auxil, &h->eval, rule)) {
	    b = PCC_FALSE;
	    c = rule(ctx);
	    a = pcc_lr_answer__create(ctx->auxil, PCC_LR_ANSWER_CHUNK, ctx->pos + ctx->cur);
	    a->data.chunk = c;
	    pcc_lr_table__hold_answer(ctx->auxil, &ctx->lrtable, p, a);
	}
    }
    if (b) {
	if (a != NULL) {
	    ctx->cur = a->pos - ctx->pos;
	    switch (a->type) {
	    case PCC_LR_ANSWER_LR:
		if (a->data.lr->head == NULL) {
		    a->data.lr->head = pcc_lr_head__create(ctx->auxil, rule);
		    pcc_lr_table__hold_head(ctx->auxil, &ctx->lrtable, p, a->data.lr->head);
		}
		{
		    size_t i = ctx->lrstack.len;
		    while (i > 0) {
			i--;
			if (ctx->lrstack.buf[i]->head == a->data.lr->head)
			    break;
			ctx->lrstack.buf[i]->head = a->data.lr->head;
			pcc_rule_set__add(ctx->auxil, &a->data.lr->head->invol, ctx->lrstack.buf[i]->rule);
		    }
		}
		c = a->data.lr->seed;
		break;
	    case PCC_LR_ANSWER_CHUNK:
		c = a->data.chunk;
		break;
	    default:		/* unknown */
		break;
	    }
	} else {
	    pcc_lr_entry_t *const e = pcc_lr_entry__create(ctx->auxil, rule);
	    pcc_lr_stack__push(ctx->auxil, &ctx->lrstack, e);
	    a = pcc_lr_answer__create(ctx->auxil, PCC_LR_ANSWER_LR, p);
	    a->data.lr = e;
	    pcc_lr_table__set_answer(ctx->auxil, &ctx->lrtable, p, rule, a);
	    c = rule(ctx);
	    pcc_lr_stack__pop(ctx->auxil, &ctx->lrstack);
	    a->pos = ctx->pos + ctx->cur;
	    if (e->head == NULL) {
		pcc_lr_answer__set_chunk(ctx->auxil, a, c);
	    } else {
		e->seed = c;
		h = a->data.lr->head;
		if (h->rule != rule) {
		    c = a->data.lr->seed;
		    a = pcc_lr_answer__create(ctx->auxil, PCC_LR_ANSWER_CHUNK, ctx->pos + ctx->cur);
		    a->data.chunk = c;
		    pcc_lr_table__hold_answer(ctx->auxil, &ctx->lrtable, p, a);
		} else {
		    pcc_lr_answer__set_chunk(ctx->auxil, a, a->data.lr->seed);
		    if (a->data.chunk == NULL) {
			c = NULL;
		    } else {
			pcc_lr_table__set_head(ctx->auxil, &ctx->lrtable, p, h);
			for (;;) {
			    ctx->cur = p - ctx->pos;
			    pcc_rule_set__copy(ctx->auxil, &h->eval, &h->invol);
			    c = rule(ctx);
			    if (c == NULL || ctx->pos + ctx->cur <= a->pos)
				break;
			    pcc_lr_answer__set_chunk(ctx->auxil, a, c);
			    a->pos = ctx->pos + ctx->cur;
			}
			pcc_thunk_chunk__destroy(ctx->auxil, c);
			pcc_lr_table__set_head(ctx->auxil, &ctx->lrtable, p, NULL);
			ctx->cur = a->pos - ctx->pos;
			c = a->data.chunk;
		    }
		}
	    }
	}
    }
    if (c == NULL)
	return PCC_FALSE;
    if (value == NULL)
	value = &null;
    memset(value, 0, sizeof(pcc_value_t));	/* in case */
    pcc_thunk_array__add(ctx->auxil, thunks, pcc_thunk__create_node(ctx->auxil, &c->thunks, value));
    return PCC_TRUE;
}

static void pcc_do_action(gml_context_t * ctx, const pcc_thunk_array_t * thunks, pcc_value_t * value)
{
    size_t i;
    for (i = 0; i < thunks->len; i++) {
	pcc_thunk_t *const thunk = thunks->buf[i];
	switch (thunk->type) {
	case PCC_THUNK_LEAF:
	    thunk->data.leaf.action(ctx, thunk, value);
	    break;
	case PCC_THUNK_NODE:
	    pcc_do_action(ctx, thunk->data.node.thunks, thunk->data.node.value);
	    break;
	default:		/* unknown */
	    break;
	}
    }
}

static void pcc_action_some_items_0(gml_context_t * __pcc_ctx, pcc_thunk_t * __pcc_in, pcc_value_t * __pcc_out)
{				/* generated by generate() line 4311 */
#define auxil (__pcc_ctx->auxil)
    if (auxil) {
    }
#define __ (*__pcc_out)
    if (__pcc_out) {
    }
#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0)
    if (__pcc_in) {
    }
#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start))
#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end))
    switcher();
#undef _0e
#undef _0s
#undef _0
#undef __
#undef auxil
}

static void pcc_action_some_items_1(gml_context_t * __pcc_ctx, pcc_thunk_t * __pcc_in, pcc_value_t * __pcc_out)
{				/* generated by generate() line 4311 */
#define auxil (__pcc_ctx->auxil)
    if (auxil) {
    }
#define __ (*__pcc_out)
    if (__pcc_out) {
    }
#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0)
    if (__pcc_in) {
    }
#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start))
#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end))
    printf("pairmode=%d\n", pairmode);
    dopair();
    pairmode = 0;
#undef _0e
#undef _0s
#undef _0
#undef __
#undef auxil
}

static void pcc_action_list2_0(gml_context_t * __pcc_ctx, pcc_thunk_t * __pcc_in, pcc_value_t * __pcc_out)
{				/* generated by generate() line 4311 */
#define auxil (__pcc_ctx->auxil)
    if (auxil) {
    }
#define __ (*__pcc_out)
    if (__pcc_out) {
    }
#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0)
    if (__pcc_in) {
    }
#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start))
#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end))
    adder();
    gtype = 0;
#undef _0e
#undef _0s
#undef _0
#undef __
#undef auxil
}

static void pcc_action_pair_0(gml_context_t * __pcc_ctx, pcc_thunk_t * __pcc_in, pcc_value_t * __pcc_out)
{				/* generated by generate() line 4311 */
#define auxil (__pcc_ctx->auxil)
    if (auxil) {
    }
#define __ (*__pcc_out)
    if (__pcc_out) {
    }
#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0)
    if (__pcc_in) {
    }
#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start))
#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end))
    lastpairid = gmlstrdup(lastid);
#undef _0e
#undef _0s
#undef _0
#undef __
#undef auxil
}

static void pcc_action_pair_1(gml_context_t * __pcc_ctx, pcc_thunk_t * __pcc_in, pcc_value_t * __pcc_out)
{				/* generated by generate() line 4311 */
#define auxil (__pcc_ctx->auxil)
    if (auxil) {
    }
#define __ (*__pcc_out)
    if (__pcc_out) {
    }
#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0)
    if (__pcc_in) {
    }
#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start))
#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end))
    pairmode = 1;
    printf("'%s' '%s' (id string)\n", lastid, laststring);
#undef _0e
#undef _0s
#undef _0
#undef __
#undef auxil
}

static void pcc_action_pair_2(gml_context_t * __pcc_ctx, pcc_thunk_t * __pcc_in, pcc_value_t * __pcc_out)
{				/* generated by generate() line 4311 */
#define auxil (__pcc_ctx->auxil)
    if (auxil) {
    }
#define __ (*__pcc_out)
    if (__pcc_out) {
    }
#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0)
    if (__pcc_in) {
    }
#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start))
#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end))
    lastpairid = gmlstrdup(lastid);
#undef _0e
#undef _0s
#undef _0
#undef __
#undef auxil
}

static void pcc_action_pair_3(gml_context_t * __pcc_ctx, pcc_thunk_t * __pcc_in, pcc_value_t * __pcc_out)
{				/* generated by generate() line 4311 */
#define auxil (__pcc_ctx->auxil)
    if (auxil) {
    }
#define __ (*__pcc_out)
    if (__pcc_out) {
    }
#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0)
    if (__pcc_in) {
    }
#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start))
#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end))
    pairmode = 2;
    printf("'%s' '%s' (id id)\n", lastpairid, lastid);
#undef _0e
#undef _0s
#undef _0
#undef __
#undef auxil
}

static void pcc_action_pair_4(gml_context_t * __pcc_ctx, pcc_thunk_t * __pcc_in, pcc_value_t * __pcc_out)
{				/* generated by generate() line 4311 */
#define auxil (__pcc_ctx->auxil)
    if (auxil) {
    }
#define __ (*__pcc_out)
    if (__pcc_out) {
    }
#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0)
    if (__pcc_in) {
    }
#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start))
#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end))
    lastpairid = gmlstrdup(lastid);
#undef _0e
#undef _0s
#undef _0
#undef __
#undef auxil
}

static void pcc_action_pair_5(gml_context_t * __pcc_ctx, pcc_thunk_t * __pcc_in, pcc_value_t * __pcc_out)
{				/* generated by generate() line 4311 */
#define auxil (__pcc_ctx->auxil)
    if (auxil) {
    }
#define __ (*__pcc_out)
    if (__pcc_out) {
    }
#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0)
    if (__pcc_in) {
    }
#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start))
#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end))
    pairmode = 3;
    printf("'%s' '%s' (id fpnum)\n", lastid, lastfpnum);
#undef _0e
#undef _0s
#undef _0
#undef __
#undef auxil
}

static void pcc_action_pair_6(gml_context_t * __pcc_ctx, pcc_thunk_t * __pcc_in, pcc_value_t * __pcc_out)
{				/* generated by generate() line 4311 */
#define auxil (__pcc_ctx->auxil)
    if (auxil) {
    }
#define __ (*__pcc_out)
    if (__pcc_out) {
    }
#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0)
    if (__pcc_in) {
    }
#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start))
#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end))
    lastpairid = gmlstrdup(lastid);
#undef _0e
#undef _0s
#undef _0
#undef __
#undef auxil
}

static void pcc_action_pair_7(gml_context_t * __pcc_ctx, pcc_thunk_t * __pcc_in, pcc_value_t * __pcc_out)
{				/* generated by generate() line 4311 */
#define auxil (__pcc_ctx->auxil)
    if (auxil) {
    }
#define __ (*__pcc_out)
    if (__pcc_out) {
    }
#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0)
    if (__pcc_in) {
    }
#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start))
#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end))
    pairmode = 4;
    printf("'%s' '%s' (id digit)\n", lastid, lastnum);
#undef _0e
#undef _0s
#undef _0
#undef __
#undef auxil
}

static void pcc_action_digit_0(gml_context_t * __pcc_ctx, pcc_thunk_t * __pcc_in, pcc_value_t * __pcc_out)
{				/* generated by generate() line 4311 */
#define auxil (__pcc_ctx->auxil)
    if (auxil) {
    }
#define __ (*__pcc_out)
    if (__pcc_out) {
    }
#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0)
    if (__pcc_in) {
    }
#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start))
#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end))
#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0])
#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start))
#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end))
    lastnum = gmlstrdup(_1);
#undef _1e
#undef _1s
#undef _1
#undef _0e
#undef _0s
#undef _0
#undef __
#undef auxil
}

static void pcc_action_fpnum_0(gml_context_t * __pcc_ctx, pcc_thunk_t * __pcc_in, pcc_value_t * __pcc_out)
{				/* generated by generate() line 4311 */
#define auxil (__pcc_ctx->auxil)
    if (auxil) {
    }
#define __ (*__pcc_out)
    if (__pcc_out) {
    }
#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0)
    if (__pcc_in) {
    }
#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start))
#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end))
#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0])
#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start))
#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end))
    lastfpnum = gmlstrdup(_1);
#undef _1e
#undef _1s
#undef _1
#undef _0e
#undef _0s
#undef _0
#undef __
#undef auxil
}

static void pcc_action_id_0(gml_context_t * __pcc_ctx, pcc_thunk_t * __pcc_in, pcc_value_t * __pcc_out)
{				/* generated by generate() line 4311 */
#define auxil (__pcc_ctx->auxil)
    if (auxil) {
    }
#define __ (*__pcc_out)
    if (__pcc_out) {
    }
#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0)
    if (__pcc_in) {
    }
#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start))
#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end))
#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0])
#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start))
#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end))
    lastid = gmlstrdup(_1);
#undef _1e
#undef _1s
#undef _1
#undef _0e
#undef _0s
#undef _0
#undef __
#undef auxil
}

static void pcc_action_string_0(gml_context_t * __pcc_ctx, pcc_thunk_t * __pcc_in, pcc_value_t * __pcc_out)
{				/* generated by generate() line 4311 */
#define auxil (__pcc_ctx->auxil)
    if (auxil) {
    }
#define __ (*__pcc_out)
    if (__pcc_out) {
    }
#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0)
    if (__pcc_in) {
    }
#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start))
#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end))
#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0])
#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start))
#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end))
    laststring = gmlstrdup(_1);
#undef _1e
#undef _1s
#undef _1
#undef _0e
#undef _0s
#undef _0
#undef __
#undef auxil
}

static void pcc_action_endofline_0(gml_context_t * __pcc_ctx, pcc_thunk_t * __pcc_in, pcc_value_t * __pcc_out)
{				/* generated by generate() line 4311 */
#define auxil (__pcc_ctx->auxil)
    if (auxil) {
    }
#define __ (*__pcc_out)
    if (__pcc_out) {
    }
#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0)
    if (__pcc_in) {
    }
#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start))
#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end))
#undef _0e
#undef _0s
#undef _0
#undef __
#undef auxil
}

static pcc_thunk_chunk_t *pcc_evaluate_rule_file(gml_context_t * ctx);
static pcc_thunk_chunk_t *pcc_evaluate_rule_head(gml_context_t * ctx);
static pcc_thunk_chunk_t *pcc_evaluate_rule_list(gml_context_t * ctx);
static pcc_thunk_chunk_t *pcc_evaluate_rule_some_items(gml_context_t * ctx);
static pcc_thunk_chunk_t *pcc_evaluate_rule_list2(gml_context_t * ctx);
static pcc_thunk_chunk_t *pcc_evaluate_rule_pair(gml_context_t * ctx);
static pcc_thunk_chunk_t *pcc_evaluate_rule_digit(gml_context_t * ctx);
static pcc_thunk_chunk_t *pcc_evaluate_rule_fpnum(gml_context_t * ctx);
static pcc_thunk_chunk_t *pcc_evaluate_rule_id(gml_context_t * ctx);
static pcc_thunk_chunk_t *pcc_evaluate_rule_string(gml_context_t * ctx);
static pcc_thunk_chunk_t *pcc_evaluate_rule_char(gml_context_t * ctx);
static pcc_thunk_chunk_t *pcc_evaluate_rule__(gml_context_t * ctx);
static pcc_thunk_chunk_t *pcc_evaluate_rule_space(gml_context_t * ctx);
static pcc_thunk_chunk_t *pcc_evaluate_rule_comment(gml_context_t * ctx);
static pcc_thunk_chunk_t *pcc_evaluate_rule_endofline(gml_context_t * ctx);

static pcc_thunk_chunk_t *pcc_evaluate_rule_file(gml_context_t * ctx)
{
    pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
    chunk->pos = ctx->cur;
    PCC_DEBUG(PCC_DBG_EVALUATE, "file", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
    ctx->level++;
    pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
    pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
    /* generated by generate_sequential_code() */
    if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL))
	goto L0000;
    if (!pcc_apply_rule(ctx, pcc_evaluate_rule_head, &chunk->thunks, NULL))
	goto L0000;
    if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL))
	goto L0000;
/* generated by generate_matching_string_code() */
    if (pcc_refill_buffer(ctx, 5) < 5 || (ctx->buffer.buf + ctx->cur)[0] != 'g' || (ctx->buffer.buf + ctx->cur)[1] != 'r' || (ctx->buffer.buf + ctx->cur)[2] != 'a' || (ctx->buffer.buf + ctx->cur)[3] != 'p' || (ctx->buffer.buf + ctx->cur)[4] != 'h')
	goto L0000;
    ctx->cur += 5;
    if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL))
	goto L0000;
    if (!pcc_apply_rule(ctx, pcc_evaluate_rule_list, &chunk->thunks, NULL))
	goto L0000;
    if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL))
	goto L0000;
/* generated by generate_predicating_code() */
    {
	const size_t p = ctx->cur;
	{
	    int u;
	    const size_t n = pcc_get_char_as_utf32(ctx, &u);
	    if (n == 0)
		goto L0001;
	    ctx->cur += n;
	}
	ctx->cur = p;
	goto L0000;
L0001:	;
	ctx->cur = p;
    }
    ctx->level--;
    PCC_DEBUG(PCC_DBG_MATCH, "file", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    return chunk;
L0000:;
    ctx->level--;
    PCC_DEBUG(PCC_DBG_NOMATCH, "file", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    pcc_thunk_chunk__destroy(ctx->auxil, chunk);
    return NULL;
}

static pcc_thunk_chunk_t *pcc_evaluate_rule_head(gml_context_t * ctx)
{
    pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
    chunk->pos = ctx->cur;
    PCC_DEBUG(PCC_DBG_EVALUATE, "head", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
    ctx->level++;
    pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
    pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
/* generated by generate_quantifying_code() */
    {
	int i;
	for (i = 0;; i++) {
	    const size_t p = ctx->cur;
	    const size_t n = chunk->thunks.len;
	    if (!pcc_apply_rule(ctx, pcc_evaluate_rule_pair, &chunk->thunks, NULL))
		goto L0001;
	    if (ctx->cur == p)
		break;
	    continue;
L0001:	    ;
	    ctx->cur = p;
	    pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	    break;
	}
    }
    ctx->level--;
    PCC_DEBUG(PCC_DBG_MATCH, "head", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    return chunk;
}

static pcc_thunk_chunk_t *pcc_evaluate_rule_list(gml_context_t * ctx)
{
    pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
    chunk->pos = ctx->cur;
    PCC_DEBUG(PCC_DBG_EVALUATE, "list", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
    ctx->level++;
    pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
    pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
    /* generated by generate_sequential_code() */
/* generated by generate_matching_string_code() */
    if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '[')
	goto L0000;
    ctx->cur++;
    if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL))
	goto L0000;
/* generated by generate_quantifying_code() */
    {
	int i;
	for (i = 0;; i++) {
	    const size_t p = ctx->cur;
	    const size_t n = chunk->thunks.len;
	    if (!pcc_apply_rule(ctx, pcc_evaluate_rule_some_items, &chunk->thunks, NULL))
		goto L0001;
	    if (ctx->cur == p)
		break;
	    continue;
L0001:	    ;
	    ctx->cur = p;
	    pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	    break;
	}
    }
    if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL))
	goto L0000;
/* generated by generate_matching_string_code() */
    if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != ']')
	goto L0000;
    ctx->cur++;
    if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL))
	goto L0000;
    ctx->level--;
    PCC_DEBUG(PCC_DBG_MATCH, "list", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    return chunk;
L0000:;
    ctx->level--;
    PCC_DEBUG(PCC_DBG_NOMATCH, "list", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    pcc_thunk_chunk__destroy(ctx->auxil, chunk);
    return NULL;
}

static pcc_thunk_chunk_t *pcc_evaluate_rule_some_items(gml_context_t * ctx)
{
    pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
    chunk->pos = ctx->cur;
    PCC_DEBUG(PCC_DBG_EVALUATE, "some_items", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
    ctx->level++;
    pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
    pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
/* generated by generate_alternative_code() */
    {
	const size_t p = ctx->cur;
	const size_t n = chunk->thunks.len;
	/* generated by generate_sequential_code() */
	if (!pcc_apply_rule(ctx, pcc_evaluate_rule_id, &chunk->thunks, NULL))
	    goto L0002;
/* generated by generate_thunking_action_code() */
	{
	    pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_some_items_0, 0, 0);
	    thunk->data.leaf.capt0.range.start = chunk->pos;
	    thunk->data.leaf.capt0.range.end = ctx->cur;
	    pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk);
	}
	if (!pcc_apply_rule(ctx, pcc_evaluate_rule_list2, &chunk->thunks, NULL))
	    goto L0002;
	goto L0001;
L0002:	;
	ctx->cur = p;
	pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	/* generated by generate_sequential_code() */
	if (!pcc_apply_rule(ctx, pcc_evaluate_rule_pair, &chunk->thunks, NULL))
	    goto L0003;
/* generated by generate_thunking_action_code() */
	{
	    pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_some_items_1, 0, 0);
	    thunk->data.leaf.capt0.range.start = chunk->pos;
	    thunk->data.leaf.capt0.range.end = ctx->cur;
	    pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk);
	}
	goto L0001;
L0003:	;
	ctx->cur = p;
	pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	goto L0000;
L0001:	;
    }
    ctx->level--;
    PCC_DEBUG(PCC_DBG_MATCH, "some_items", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    return chunk;
L0000:;
    ctx->level--;
    PCC_DEBUG(PCC_DBG_NOMATCH, "some_items", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    pcc_thunk_chunk__destroy(ctx->auxil, chunk);
    return NULL;
}

static pcc_thunk_chunk_t *pcc_evaluate_rule_list2(gml_context_t * ctx)
{
    pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
    chunk->pos = ctx->cur;
    PCC_DEBUG(PCC_DBG_EVALUATE, "list2", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
    ctx->level++;
    pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
    pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
    /* generated by generate_sequential_code() */
/* generated by generate_matching_string_code() */
    if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '[')
	goto L0000;
    ctx->cur++;
    if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL))
	goto L0000;
/* generated by generate_quantifying_code() */
    {
	int i;
	for (i = 0;; i++) {
	    const size_t p = ctx->cur;
	    const size_t n = chunk->thunks.len;
	    if (!pcc_apply_rule(ctx, pcc_evaluate_rule_some_items, &chunk->thunks, NULL))
		goto L0001;
	    if (ctx->cur == p)
		break;
	    continue;
L0001:	    ;
	    ctx->cur = p;
	    pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	    break;
	}
    }
    if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL))
	goto L0000;
/* generated by generate_matching_string_code() */
    if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != ']')
	goto L0000;
    ctx->cur++;
    if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL))
	goto L0000;
/* generated by generate_thunking_action_code() */
    {
	pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_list2_0, 0, 0);
	thunk->data.leaf.capt0.range.start = chunk->pos;
	thunk->data.leaf.capt0.range.end = ctx->cur;
	pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk);
    }
    ctx->level--;
    PCC_DEBUG(PCC_DBG_MATCH, "list2", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    return chunk;
L0000:;
    ctx->level--;
    PCC_DEBUG(PCC_DBG_NOMATCH, "list2", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    pcc_thunk_chunk__destroy(ctx->auxil, chunk);
    return NULL;
}

static pcc_thunk_chunk_t *pcc_evaluate_rule_pair(gml_context_t * ctx)
{
    pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
    chunk->pos = ctx->cur;
    PCC_DEBUG(PCC_DBG_EVALUATE, "pair", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
    ctx->level++;
    pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
    pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
/* generated by generate_alternative_code() */
    {
	const size_t p = ctx->cur;
	const size_t n = chunk->thunks.len;
	/* generated by generate_sequential_code() */
	/* generated by generate_sequential_code() */
	if (!pcc_apply_rule(ctx, pcc_evaluate_rule_id, &chunk->thunks, NULL))
	    goto L0002;
/* generated by generate_thunking_action_code() */
	{
	    pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_pair_0, 0, 0);
	    thunk->data.leaf.capt0.range.start = chunk->pos;
	    thunk->data.leaf.capt0.range.end = ctx->cur;
	    pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk);
	}
	if (!pcc_apply_rule(ctx, pcc_evaluate_rule_string, &chunk->thunks, NULL))
	    goto L0002;
/* generated by generate_thunking_action_code() */
	{
	    pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_pair_1, 0, 0);
	    thunk->data.leaf.capt0.range.start = chunk->pos;
	    thunk->data.leaf.capt0.range.end = ctx->cur;
	    pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk);
	}
	goto L0001;
L0002:	;
	ctx->cur = p;
	pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	/* generated by generate_sequential_code() */
	/* generated by generate_sequential_code() */
	if (!pcc_apply_rule(ctx, pcc_evaluate_rule_id, &chunk->thunks, NULL))
	    goto L0003;
/* generated by generate_thunking_action_code() */
	{
	    pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_pair_2, 0, 0);
	    thunk->data.leaf.capt0.range.start = chunk->pos;
	    thunk->data.leaf.capt0.range.end = ctx->cur;
	    pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk);
	}
	if (!pcc_apply_rule(ctx, pcc_evaluate_rule_id, &chunk->thunks, NULL))
	    goto L0003;
/* generated by generate_thunking_action_code() */
	{
	    pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_pair_3, 0, 0);
	    thunk->data.leaf.capt0.range.start = chunk->pos;
	    thunk->data.leaf.capt0.range.end = ctx->cur;
	    pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk);
	}
	goto L0001;
L0003:	;
	ctx->cur = p;
	pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	/* generated by generate_sequential_code() */
	/* generated by generate_sequential_code() */
	if (!pcc_apply_rule(ctx, pcc_evaluate_rule_id, &chunk->thunks, NULL))
	    goto L0004;
/* generated by generate_thunking_action_code() */
	{
	    pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_pair_4, 0, 0);
	    thunk->data.leaf.capt0.range.start = chunk->pos;
	    thunk->data.leaf.capt0.range.end = ctx->cur;
	    pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk);
	}
	if (!pcc_apply_rule(ctx, pcc_evaluate_rule_fpnum, &chunk->thunks, NULL))
	    goto L0004;
/* generated by generate_thunking_action_code() */
	{
	    pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_pair_5, 0, 0);
	    thunk->data.leaf.capt0.range.start = chunk->pos;
	    thunk->data.leaf.capt0.range.end = ctx->cur;
	    pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk);
	}
	goto L0001;
L0004:	;
	ctx->cur = p;
	pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	/* generated by generate_sequential_code() */
	/* generated by generate_sequential_code() */
	if (!pcc_apply_rule(ctx, pcc_evaluate_rule_id, &chunk->thunks, NULL))
	    goto L0005;
/* generated by generate_thunking_action_code() */
	{
	    pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_pair_6, 0, 0);
	    thunk->data.leaf.capt0.range.start = chunk->pos;
	    thunk->data.leaf.capt0.range.end = ctx->cur;
	    pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk);
	}
	if (!pcc_apply_rule(ctx, pcc_evaluate_rule_digit, &chunk->thunks, NULL))
	    goto L0005;
/* generated by generate_thunking_action_code() */
	{
	    pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_pair_7, 0, 0);
	    thunk->data.leaf.capt0.range.start = chunk->pos;
	    thunk->data.leaf.capt0.range.end = ctx->cur;
	    pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk);
	}
	goto L0001;
L0005:	;
	ctx->cur = p;
	pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	goto L0000;
L0001:	;
    }
    ctx->level--;
    PCC_DEBUG(PCC_DBG_MATCH, "pair", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    return chunk;
L0000:;
    ctx->level--;
    PCC_DEBUG(PCC_DBG_NOMATCH, "pair", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    pcc_thunk_chunk__destroy(ctx->auxil, chunk);
    return NULL;
}

static pcc_thunk_chunk_t *pcc_evaluate_rule_digit(gml_context_t * ctx)
{
    pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
    chunk->pos = ctx->cur;
    PCC_DEBUG(PCC_DBG_EVALUATE, "digit", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
    ctx->level++;
    pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
    pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1);
    /* generated by generate_sequential_code() */
/* generated by generate_capturing_code() */
    {
	const size_t p = ctx->cur;
	size_t q;
	/* generated by generate_sequential_code() */
/* generated by generate_quantifying_code() */
	{
	    const size_t p = ctx->cur;
	    const size_t n = chunk->thunks.len;
/* generated by generate_alternative_code() */
	    {
		const size_t p = ctx->cur;
		const size_t n = chunk->thunks.len;
/* generated by generate_matching_string_code() */
		if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '-')
		    goto L0003;
		ctx->cur++;
		goto L0002;
L0003:		;
		ctx->cur = p;
		pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
/* generated by generate_matching_string_code() */
		if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '+')
		    goto L0004;
		ctx->cur++;
		goto L0002;
L0004:		;
		ctx->cur = p;
		pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
		goto L0001;
L0002:		;
	    }
	    goto L0005;
L0001:	    ;
	    ctx->cur = p;
	    pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
L0005:	    ;
	}
/* generated by generate_quantifying_code() */
	{
	    const size_t p0 = ctx->cur;
	    const size_t n0 = chunk->thunks.len;
	    int i;
	    for (i = 0;; i++) {
		const size_t p = ctx->cur;
		const size_t n = chunk->thunks.len;
		{
		    int u;
		    const size_t n = pcc_get_char_as_utf32(ctx, &u);
		    if (n == 0)
			goto L0006;
		    if (!((u >= 0x000030 && u <= 0x000039)
			))
			goto L0006;
		    ctx->cur += n;
		}
		if (ctx->cur == p)
		    break;
		continue;
L0006:		;
		ctx->cur = p;
		pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
		break;
	    }
	    if (i < 1) {
		ctx->cur = p0;
		pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0);
		goto L0000;
	    }
	}
	q = ctx->cur;
	chunk->capts.buf[0].range.start = p;
	chunk->capts.buf[0].range.end = q;
    }
    if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL))
	goto L0000;
/* generated by generate_thunking_action_code() */
    {
	pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_digit_0, 0, 1);
	thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]);
	thunk->data.leaf.capt0.range.start = chunk->pos;
	thunk->data.leaf.capt0.range.end = ctx->cur;
	pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk);
    }
    ctx->level--;
    PCC_DEBUG(PCC_DBG_MATCH, "digit", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    return chunk;
L0000:;
    ctx->level--;
    PCC_DEBUG(PCC_DBG_NOMATCH, "digit", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    pcc_thunk_chunk__destroy(ctx->auxil, chunk);
    return NULL;
}

static pcc_thunk_chunk_t *pcc_evaluate_rule_fpnum(gml_context_t * ctx)
{
    pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
    chunk->pos = ctx->cur;
    PCC_DEBUG(PCC_DBG_EVALUATE, "fpnum", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
    ctx->level++;
    pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
    pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1);
    /* generated by generate_sequential_code() */
/* generated by generate_capturing_code() */
    {
	const size_t p = ctx->cur;
	size_t q;
	/* generated by generate_sequential_code() */
/* generated by generate_quantifying_code() */
	{
	    const size_t p = ctx->cur;
	    const size_t n = chunk->thunks.len;
/* generated by generate_alternative_code() */
	    {
		const size_t p = ctx->cur;
		const size_t n = chunk->thunks.len;
/* generated by generate_matching_string_code() */
		if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '-')
		    goto L0003;
		ctx->cur++;
		goto L0002;
L0003:		;
		ctx->cur = p;
		pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
/* generated by generate_matching_string_code() */
		if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '+')
		    goto L0004;
		ctx->cur++;
		goto L0002;
L0004:		;
		ctx->cur = p;
		pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
		goto L0001;
L0002:		;
	    }
	    goto L0005;
L0001:	    ;
	    ctx->cur = p;
	    pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
L0005:	    ;
	}
/* generated by generate_quantifying_code() */
	{
	    int i;
	    for (i = 0;; i++) {
		const size_t p = ctx->cur;
		const size_t n = chunk->thunks.len;
		{
		    int u;
		    const size_t n = pcc_get_char_as_utf32(ctx, &u);
		    if (n == 0)
			goto L0006;
		    if (!((u >= 0x000030 && u <= 0x000039)
			))
			goto L0006;
		    ctx->cur += n;
		}
		if (ctx->cur == p)
		    break;
		continue;
L0006:		;
		ctx->cur = p;
		pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
		break;
	    }
	}
/* generated by generate_matching_string_code() */
	if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '.')
	    goto L0000;
	ctx->cur++;
/* generated by generate_quantifying_code() */
	{
	    const size_t p0 = ctx->cur;
	    const size_t n0 = chunk->thunks.len;
	    int i;
	    for (i = 0;; i++) {
		const size_t p = ctx->cur;
		const size_t n = chunk->thunks.len;
		{
		    int u;
		    const size_t n = pcc_get_char_as_utf32(ctx, &u);
		    if (n == 0)
			goto L0007;
		    if (!((u >= 0x000030 && u <= 0x000039)
			))
			goto L0007;
		    ctx->cur += n;
		}
		if (ctx->cur == p)
		    break;
		continue;
L0007:		;
		ctx->cur = p;
		pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
		break;
	    }
	    if (i < 1) {
		ctx->cur = p0;
		pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0);
		goto L0000;
	    }
	}
/* generated by generate_quantifying_code() */
	{
	    const size_t p = ctx->cur;
	    const size_t n = chunk->thunks.len;
	    /* generated by generate_sequential_code() */
	    {
		int u;
		const size_t n = pcc_get_char_as_utf32(ctx, &u);
		if (n == 0)
		    goto L0008;
		if (!(u == 0x000027 || u == 0x000065 || u == 0x000027 || u == 0x000027 || u == 0x000045 || u == 0x000027))
		    goto L0008;
		ctx->cur += n;
	    }
/* generated by generate_quantifying_code() */
	    {
		const size_t p = ctx->cur;
		const size_t n = chunk->thunks.len;
/* generated by generate_alternative_code() */
		{
		    const size_t p = ctx->cur;
		    const size_t n = chunk->thunks.len;
/* generated by generate_matching_string_code() */
		    if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '-')
			goto L0011;
		    ctx->cur++;
		    goto L0010;
L0011:		    ;
		    ctx->cur = p;
		    pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
/* generated by generate_matching_string_code() */
		    if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '+')
			goto L0012;
		    ctx->cur++;
		    goto L0010;
L0012:		    ;
		    ctx->cur = p;
		    pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
		    goto L0009;
L0010:		    ;
		}
		goto L0013;
L0009:		;
		ctx->cur = p;
		pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
L0013:		;
	    }
/* generated by generate_quantifying_code() */
	    {
		const size_t p0 = ctx->cur;
		const size_t n0 = chunk->thunks.len;
		int i;
		for (i = 0;; i++) {
		    const size_t p = ctx->cur;
		    const size_t n = chunk->thunks.len;
		    {
			int u;
			const size_t n = pcc_get_char_as_utf32(ctx, &u);
			if (n == 0)
			    goto L0014;
			if (!((u >= 0x000030 && u <= 0x000039)
			    ))
			    goto L0014;
			ctx->cur += n;
		    }
		    if (ctx->cur == p)
			break;
		    continue;
L0014:		    ;
		    ctx->cur = p;
		    pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
		    break;
		}
		if (i < 1) {
		    ctx->cur = p0;
		    pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0);
		    goto L0008;
		}
	    }
	    goto L0015;
L0008:	    ;
	    ctx->cur = p;
	    pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
L0015:	    ;
	}
	q = ctx->cur;
	chunk->capts.buf[0].range.start = p;
	chunk->capts.buf[0].range.end = q;
    }
    if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL))
	goto L0000;
/* generated by generate_thunking_action_code() */
    {
	pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_fpnum_0, 0, 1);
	thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]);
	thunk->data.leaf.capt0.range.start = chunk->pos;
	thunk->data.leaf.capt0.range.end = ctx->cur;
	pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk);
    }
    ctx->level--;
    PCC_DEBUG(PCC_DBG_MATCH, "fpnum", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    return chunk;
L0000:;
    ctx->level--;
    PCC_DEBUG(PCC_DBG_NOMATCH, "fpnum", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    pcc_thunk_chunk__destroy(ctx->auxil, chunk);
    return NULL;
}

static pcc_thunk_chunk_t *pcc_evaluate_rule_id(gml_context_t * ctx)
{
    pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
    chunk->pos = ctx->cur;
    PCC_DEBUG(PCC_DBG_EVALUATE, "id", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
    ctx->level++;
    pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
    pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1);
    /* generated by generate_sequential_code() */
/* generated by generate_capturing_code() */
    {
	const size_t p = ctx->cur;
	size_t q;
	/* generated by generate_sequential_code() */
/* generated by generate_quantifying_code() */
	{
	    const size_t p0 = ctx->cur;
	    const size_t n0 = chunk->thunks.len;
	    int i;
	    for (i = 0;; i++) {
		const size_t p = ctx->cur;
		const size_t n = chunk->thunks.len;
		{
		    int u;
		    const size_t n = pcc_get_char_as_utf32(ctx, &u);
		    if (n == 0)
			goto L0001;
		    if (!((u >= 0x000061 && u <= 0x00007a) || (u >= 0x000041 && u <= 0x00005a) || u == 0x00005f))
			goto L0001;
		    ctx->cur += n;
		}
		if (ctx->cur == p)
		    break;
		continue;
L0001:		;
		ctx->cur = p;
		pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
		break;
	    }
	    if (i < 1) {
		ctx->cur = p0;
		pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0);
		goto L0000;
	    }
	}
/* generated by generate_quantifying_code() */
	{
	    int i;
	    for (i = 0;; i++) {
		const size_t p = ctx->cur;
		const size_t n = chunk->thunks.len;
		{
		    int u;
		    const size_t n = pcc_get_char_as_utf32(ctx, &u);
		    if (n == 0)
			goto L0002;
		    if (!((u >= 0x000061 && u <= 0x00007a) || (u >= 0x000041 && u <= 0x00005a) || u == 0x00005f || (u >= 0x000030 && u <= 0x000039)
			))
			goto L0002;
		    ctx->cur += n;
		}
		if (ctx->cur == p)
		    break;
		continue;
L0002:		;
		ctx->cur = p;
		pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
		break;
	    }
	}
	q = ctx->cur;
	chunk->capts.buf[0].range.start = p;
	chunk->capts.buf[0].range.end = q;
    }
    if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL))
	goto L0000;
/* generated by generate_thunking_action_code() */
    {
	pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_id_0, 0, 1);
	thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]);
	thunk->data.leaf.capt0.range.start = chunk->pos;
	thunk->data.leaf.capt0.range.end = ctx->cur;
	pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk);
    }
    ctx->level--;
    PCC_DEBUG(PCC_DBG_MATCH, "id", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    return chunk;
L0000:;
    ctx->level--;
    PCC_DEBUG(PCC_DBG_NOMATCH, "id", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    pcc_thunk_chunk__destroy(ctx->auxil, chunk);
    return NULL;
}

static pcc_thunk_chunk_t *pcc_evaluate_rule_string(gml_context_t * ctx)
{
    pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
    chunk->pos = ctx->cur;
    PCC_DEBUG(PCC_DBG_EVALUATE, "string", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
    ctx->level++;
    pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
    pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1);
    /* generated by generate_sequential_code() */
/* generated by generate_matching_string_code() */
    if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '\"')
	goto L0000;
    ctx->cur++;
/* generated by generate_capturing_code() */
    {
	const size_t p = ctx->cur;
	size_t q;
/* generated by generate_quantifying_code() */
	{
	    int i;
	    for (i = 0;; i++) {
		const size_t p = ctx->cur;
		const size_t n = chunk->thunks.len;
		if (!pcc_apply_rule(ctx, pcc_evaluate_rule_char, &chunk->thunks, NULL))
		    goto L0001;
		if (ctx->cur == p)
		    break;
		continue;
L0001:		;
		ctx->cur = p;
		pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
		break;
	    }
	}
	q = ctx->cur;
	chunk->capts.buf[0].range.start = p;
	chunk->capts.buf[0].range.end = q;
    }
/* generated by generate_matching_string_code() */
    if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '\"')
	goto L0000;
    ctx->cur++;
    if (!pcc_apply_rule(ctx, pcc_evaluate_rule__, &chunk->thunks, NULL))
	goto L0000;
/* generated by generate_thunking_action_code() */
    {
	pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_string_0, 0, 1);
	thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]);
	thunk->data.leaf.capt0.range.start = chunk->pos;
	thunk->data.leaf.capt0.range.end = ctx->cur;
	pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk);
    }
    ctx->level--;
    PCC_DEBUG(PCC_DBG_MATCH, "string", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    return chunk;
L0000:;
    ctx->level--;
    PCC_DEBUG(PCC_DBG_NOMATCH, "string", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    pcc_thunk_chunk__destroy(ctx->auxil, chunk);
    return NULL;
}

static pcc_thunk_chunk_t *pcc_evaluate_rule_char(gml_context_t * ctx)
{
    pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
    chunk->pos = ctx->cur;
    PCC_DEBUG(PCC_DBG_EVALUATE, "char", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
    ctx->level++;
    pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
    pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
/* generated by generate_alternative_code() */
    {
	const size_t p = ctx->cur;
	const size_t n = chunk->thunks.len;
	/* generated by generate_sequential_code() */
/* generated by generate_matching_string_code() */
	if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '\\')
	    goto L0002;
	ctx->cur++;
/* generated by generate_matching_string_code() */
	if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '\"')
	    goto L0002;
	ctx->cur++;
	goto L0001;
L0002:	;
	ctx->cur = p;
	pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	/* generated by generate_sequential_code() */
/* generated by generate_matching_string_code() */
	if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '\\')
	    goto L0003;
	ctx->cur++;
/* generated by generate_matching_string_code() */
	if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '\\')
	    goto L0003;
	ctx->cur++;
	goto L0001;
L0003:	;
	ctx->cur = p;
	pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	/* generated by generate_sequential_code() */
/* generated by generate_matching_string_code() */
	if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '\\')
	    goto L0004;
	ctx->cur++;
/* generated by generate_matching_string_code() */
	if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != 'b')
	    goto L0004;
	ctx->cur++;
	goto L0001;
L0004:	;
	ctx->cur = p;
	pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	/* generated by generate_sequential_code() */
/* generated by generate_matching_string_code() */
	if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '\\')
	    goto L0005;
	ctx->cur++;
/* generated by generate_matching_string_code() */
	if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != 'f')
	    goto L0005;
	ctx->cur++;
	goto L0001;
L0005:	;
	ctx->cur = p;
	pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	/* generated by generate_sequential_code() */
/* generated by generate_matching_string_code() */
	if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '\\')
	    goto L0006;
	ctx->cur++;
/* generated by generate_matching_string_code() */
	if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != 'n')
	    goto L0006;
	ctx->cur++;
	goto L0001;
L0006:	;
	ctx->cur = p;
	pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	/* generated by generate_sequential_code() */
/* generated by generate_matching_string_code() */
	if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '\\')
	    goto L0007;
	ctx->cur++;
/* generated by generate_matching_string_code() */
	if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != 'r')
	    goto L0007;
	ctx->cur++;
	goto L0001;
L0007:	;
	ctx->cur = p;
	pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	/* generated by generate_sequential_code() */
/* generated by generate_matching_string_code() */
	if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '\\')
	    goto L0008;
	ctx->cur++;
/* generated by generate_matching_string_code() */
	if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != 't')
	    goto L0008;
	ctx->cur++;
	goto L0001;
L0008:	;
	ctx->cur = p;
	pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	/* generated by generate_sequential_code() */
/* generated by generate_predicating_code() */
	{
	    const size_t p = ctx->cur;
/* generated by generate_matching_string_code() */
	    if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '\"')
		goto L0010;
	    ctx->cur++;
	    ctx->cur = p;
	    goto L0009;
L0010:	    ;
	    ctx->cur = p;
	}
	{
	    int u;
	    const size_t n = pcc_get_char_as_utf32(ctx, &u);
	    if (n == 0)
		goto L0009;
	    ctx->cur += n;
	}
	goto L0001;
L0009:	;
	ctx->cur = p;
	pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	goto L0000;
L0001:	;
    }
    ctx->level--;
    PCC_DEBUG(PCC_DBG_MATCH, "char", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    return chunk;
L0000:;
    ctx->level--;
    PCC_DEBUG(PCC_DBG_NOMATCH, "char", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    pcc_thunk_chunk__destroy(ctx->auxil, chunk);
    return NULL;
}

static pcc_thunk_chunk_t *pcc_evaluate_rule__(gml_context_t * ctx)
{
    pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
    chunk->pos = ctx->cur;
    PCC_DEBUG(PCC_DBG_EVALUATE, "_", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
    ctx->level++;
    pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
    pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
/* generated by generate_quantifying_code() */
    {
	int i;
	for (i = 0;; i++) {
	    const size_t p = ctx->cur;
	    const size_t n = chunk->thunks.len;
/* generated by generate_alternative_code() */
	    {
		const size_t p = ctx->cur;
		const size_t n = chunk->thunks.len;
		if (!pcc_apply_rule(ctx, pcc_evaluate_rule_space, &chunk->thunks, NULL))
		    goto L0003;
		goto L0002;
L0003:		;
		ctx->cur = p;
		pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
		if (!pcc_apply_rule(ctx, pcc_evaluate_rule_comment, &chunk->thunks, NULL))
		    goto L0004;
		goto L0002;
L0004:		;
		ctx->cur = p;
		pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
		goto L0001;
L0002:		;
	    }
	    if (ctx->cur == p)
		break;
	    continue;
L0001:	    ;
	    ctx->cur = p;
	    pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	    break;
	}
    }
    ctx->level--;
    PCC_DEBUG(PCC_DBG_MATCH, "_", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    return chunk;
}

static pcc_thunk_chunk_t *pcc_evaluate_rule_space(gml_context_t * ctx)
{
    pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
    chunk->pos = ctx->cur;
    PCC_DEBUG(PCC_DBG_EVALUATE, "space", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
    ctx->level++;
    pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
    pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
/* generated by generate_alternative_code() */
    {
	const size_t p = ctx->cur;
	const size_t n = chunk->thunks.len;
/* generated by generate_matching_string_code() */
	if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != ' ')
	    goto L0002;
	ctx->cur++;
	goto L0001;
L0002:	;
	ctx->cur = p;
	pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
/* generated by generate_matching_string_code() */
	if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '\t')
	    goto L0003;
	ctx->cur++;
	goto L0001;
L0003:	;
	ctx->cur = p;
	pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	if (!pcc_apply_rule(ctx, pcc_evaluate_rule_endofline, &chunk->thunks, NULL))
	    goto L0004;
	goto L0001;
L0004:	;
	ctx->cur = p;
	pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	goto L0000;
L0001:	;
    }
    ctx->level--;
    PCC_DEBUG(PCC_DBG_MATCH, "space", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    return chunk;
L0000:;
    ctx->level--;
    PCC_DEBUG(PCC_DBG_NOMATCH, "space", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    pcc_thunk_chunk__destroy(ctx->auxil, chunk);
    return NULL;
}

static pcc_thunk_chunk_t *pcc_evaluate_rule_comment(gml_context_t * ctx)
{
    pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
    chunk->pos = ctx->cur;
    PCC_DEBUG(PCC_DBG_EVALUATE, "comment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
    ctx->level++;
    pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
    pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
    /* generated by generate_sequential_code() */
/* generated by generate_matching_string_code() */
    if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '#')
	goto L0000;
    ctx->cur++;
/* generated by generate_quantifying_code() */
    {
	int i;
	for (i = 0;; i++) {
	    const size_t p = ctx->cur;
	    const size_t n = chunk->thunks.len;
	    /* generated by generate_sequential_code() */
/* generated by generate_predicating_code() */
	    {
		const size_t p = ctx->cur;
		if (!pcc_apply_rule(ctx, pcc_evaluate_rule_endofline, &chunk->thunks, NULL))
		    goto L0002;
		ctx->cur = p;
		goto L0001;
L0002:		;
		ctx->cur = p;
	    }
	    {
		int u;
		const size_t n = pcc_get_char_as_utf32(ctx, &u);
		if (n == 0)
		    goto L0001;
		ctx->cur += n;
	    }
	    if (ctx->cur == p)
		break;
	    continue;
L0001:	    ;
	    ctx->cur = p;
	    pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	    break;
	}
    }
    ctx->level--;
    PCC_DEBUG(PCC_DBG_MATCH, "comment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    return chunk;
L0000:;
    ctx->level--;
    PCC_DEBUG(PCC_DBG_NOMATCH, "comment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    pcc_thunk_chunk__destroy(ctx->auxil, chunk);
    return NULL;
}

static pcc_thunk_chunk_t *pcc_evaluate_rule_endofline(gml_context_t * ctx)
{
    pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil);
    chunk->pos = ctx->cur;
    PCC_DEBUG(PCC_DBG_EVALUATE, "endofline", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
    ctx->level++;
    pcc_value_table__resize(ctx->auxil, &chunk->values, 0);
    pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0);
    /* generated by generate_sequential_code() */
/* generated by generate_alternative_code() */
    {
	const size_t p = ctx->cur;
	const size_t n = chunk->thunks.len;
/* generated by generate_matching_string_code() */
	if (pcc_refill_buffer(ctx, 2) < 2 || (ctx->buffer.buf + ctx->cur)[0] != '\r' || (ctx->buffer.buf + ctx->cur)[1] != '\n')
	    goto L0002;
	ctx->cur += 2;
	goto L0001;
L0002:	;
	ctx->cur = p;
	pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
/* generated by generate_matching_string_code() */
	if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '\n')
	    goto L0003;
	ctx->cur++;
	goto L0001;
L0003:	;
	ctx->cur = p;
	pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
/* generated by generate_matching_string_code() */
	if (pcc_refill_buffer(ctx, 1) < 1 || ctx->buffer.buf[ctx->cur] != '\r')
	    goto L0004;
	ctx->cur++;
	goto L0001;
L0004:	;
	ctx->cur = p;
	pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
/* generated by generate_matching_string_code() */
	if (pcc_refill_buffer(ctx, 2) < 2 || (ctx->buffer.buf + ctx->cur)[0] != '\n' || (ctx->buffer.buf + ctx->cur)[1] != '\r')
	    goto L0005;
	ctx->cur += 2;
	goto L0001;
L0005:	;
	ctx->cur = p;
	pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
	goto L0000;
L0001:	;
    }
/* generated by generate_thunking_action_code() */
    {
	pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_endofline_0, 0, 0);
	thunk->data.leaf.capt0.range.start = chunk->pos;
	thunk->data.leaf.capt0.range.end = ctx->cur;
	pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk);
    }
    ctx->level--;
    PCC_DEBUG(PCC_DBG_MATCH, "endofline", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    return chunk;
L0000:;
    ctx->level--;
    PCC_DEBUG(PCC_DBG_NOMATCH, "endofline", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos));
    pcc_thunk_chunk__destroy(ctx->auxil, chunk);
    return NULL;
}

gml_context_t *gml_create(void *auxil)
{
    return pcc_context__create(auxil);
}

int gml_parse(gml_context_t * ctx, int *ret)
{
    pcc_thunk_array_t thunks;
    pcc_thunk_array__init(ctx->auxil, &thunks, PCC_ARRAYSIZE);
    if (pcc_apply_rule(ctx, pcc_evaluate_rule_file, &thunks, ret))
	pcc_do_action(ctx, &thunks, ret);
    else
	PCC_ERROR(ctx->auxil);
    pcc_commit_buffer(ctx);
    pcc_thunk_array__term(ctx->auxil, &thunks);
    return pcc_refill_buffer(ctx, 1) >= 1;
}

void gml_destroy(gml_context_t * ctx)
{
    pcc_context__destroy(ctx);
}

/* parse the gml graph data */
int gmlmain(FILE * filestream, int gmldebug)
{
    gml_context_t *ctx = (gml_context_t *) 0;
    if (!filestream) {
	/* shouldnothappen return error status */
	return (1);
    }
    /* input parameters */
    showdebug = gmldebug;
    gmlstream = filestream;
    /* update here to read from stream instead of stdin */
    /* set no error status */
    status = 0;
    /* init parser */
    init00();
    ctx = gml_create(NULL);
    /* parse the data */
    for (;;) {
	fflush(stdout);
	fflush(stderr);
	if (status) {
	    break;		/* stop at first parse error */
	}
	if (gml_parse(ctx, NULL) == 0) {
	    break;
	}
    }
    gml_destroy(ctx);
    if (status == 0) {
	/* parsed ok, now check the data. */
	copyin();
    }
    return (status);
}

/* init parser */
static void init00(void)
{

    /* data for parsed nodes. key is the string of the uniq id number, value is struct with data */
    gmln = splay_tree_new(splay_tree_compare_strings, (splay_tree_delete_key_fn) 0, (splay_tree_delete_value_fn) 0);

    /* data for parsed edges. */
    gmle = splay_tree_new(splay_tree_compare_ints, (splay_tree_delete_key_fn) 0, (splay_tree_delete_value_fn) 0);

    /* edge counter */
    ecount = 0;

    /* type of data parsed */
    gtype = 0;

    /* type of pair data */
    pairmode = 0;

    return;
}

/* switch between node[], edge[] etc. */
static void switcher(void)
{
    if (!lastid) {
	/* shouldnothappen */
	/* type of data parsed */
	gtype = 0;
	return;
    }
    /* select what kind of data is being parsed */
    if (strcmp(lastid, "node") == 0) {
	gtype = 1;
	printf("node\n");
    } else if (strcmp(lastid, "edge") == 0) {
	gtype = 2;
	printf("edge\n");
    } else {
	/* something else */
	if (gtype == 1) {
	    printf("inside node\n");
	} else if (gtype == 2) {
	    printf("inside edge\n");
	} else {
	    gtype = 0;
	    printf("something else\n");
	}
    }
    return;
}

/* handle a parsed pair */
static void dopair(void)
{
    if (status) {
	/* there has been a parse error */
	return;
    }
    if (gtype == 1) {
	/* inside a node */
	if (strcmp(lastpairid, "id") == 0) {
	    if (pairmode == 4) {
		/* example: node [ id 3 ] */
		printf("node with id %s found\n", lastnum);
		if (cur_node_id) {
		    printf("node with multiple id numbers\n");
		    /* add here routine to stop the parser */
		    status = 1;
		} else {
		    cur_node_id = gmlstrdup(lastnum);
		}
	    } else {
		printf("node id with bad format\n");
		/* add here routine to stop the parser */
		status = 1;
	    }
	} else if (strcmp(lastpairid, "label") == 0) {
	    if (pairmode == 1) {
		if (cur_node_label) {
		    printf("node with multiple labels\n");
		    /* add here routine to stop the parser */
		    status = 1;
		} else {
		    cur_node_label = gmlstrdup(laststring);
		}
	    } else {
		printf("node label with bad format\n");
		/* add here routine to stop the parser */
		status = 1;
	    }
	} else {
	    /* other node details can be added here */
	}
    } else if (gtype == 2) {
	/* inside a edge */
	/* more checks to be added here */
	if (strcmp(lastpairid, "source") == 0) {
	    if (pairmode == 4) {
		cur_edge_source = gmlstrdup(lastnum);
	    }
	} else if (strcmp(lastpairid, "target") == 0) {
	    if (pairmode == 4) {
		cur_edge_target = gmlstrdup(lastnum);
	    }
	} else if (strcmp(lastpairid, "label") == 0) {
	    if (pairmode == 1) {
		cur_edge_label = gmlstrdup(laststring);
	    }
	} else {
	    /* some other edge detail can be added here */
	}
    } else {

    }
    return;
}

/* add complete node/edge data */
static void adder(void)
{
    struct gmlnd *ndp = NULL;
    struct gmled *edp = NULL;
    if (status) {
	/* there has been a parse error */
	return;
    }
    printf("adder gtype=%d\n", gtype);
    if (gtype == 1) {
	/* node data */
	printf("add node id=%s label=%s\n", cur_node_id, cur_node_label);
	/* clear the current node data */
	ndp = dp_calloc(1, sizeof(struct gmlnd));
	ndp->id = gmlstrdup(cur_node_id);
	if (cur_node_label) {
	    /* optional label */
	    ndp->label = gmlstrdup(cur_node_label);
	}
	splay_tree_insert(gmln, (splay_tree_key) cur_node_id, (splay_tree_value) ndp);
	cur_node_id = NULL;
	cur_node_label = NULL;
    } else if (gtype == 2) {
	/* edge data */
	printf("add edge\n");
	printf("add egde source=%s target=%s label=%s\n", cur_edge_source, cur_edge_target, cur_edge_label);
	if (cur_edge_label) {
	    /* optional label */
	}
	edp = dp_calloc(1, sizeof(struct gmled));
	edp->num = ecount++;
	edp->source = gmlstrdup(cur_edge_source);
	edp->target = gmlstrdup(cur_edge_target);
	if (cur_edge_label) {
	    edp->label = gmlstrdup(cur_edge_label);
	}
	splay_tree_insert(gmle, (splay_tree_key) ecount, (splay_tree_value) edp);
	cur_edge_source = NULL;
	cur_edge_target = NULL;
	cur_edge_label = NULL;
    } else {
	/* skip */
    }
    return;
}

/* copy data from parser to layouter, at error set status to 1 */
static void copyin(void)
{
    splay_tree_node nspn;
    splay_tree_node sspn;
    splay_tree_key key;
    struct gmlnd *ndp = NULL;
    struct gmled *edp = NULL;
    long n = 0;

    printf("%s():\n", __func__);

    /* first check the node data */
    nspn = splay_tree_min(gmln);

    while (nspn) {
	key = nspn->key;
	ndp = (struct gmlnd *)nspn->value;
	printf("resulting parsed node %s with label %s\n", (char *)nspn->key, (char *)ndp->label);
	/* here the node id number is known to be correct but can be +/- 123 */
	/* to improve: use strtoll and check for signed 32 bit overflow */
	n = strtol((char *)nspn->key, NULL, 10);
	if (n < 0) {
	    printf("node with negative number %s is a error\n", (char *)nspn->key);
	    status = 1;
	}
	/* save the converted number */
	ndp->idlong = n;	/* to improve: this can overflow. */
	nspn = splay_tree_successor(gmln, key);
    }

    /* stop at error */
    if (status) {
	return;
    }

    /* scan the optional edges and all node numbers must have been defined */
    nspn = splay_tree_min(gmle);

    while (nspn) {
	key = nspn->key;
	edp = (struct gmled *)nspn->value;
	printf("edge from %s to %s label %s\n", edp->source, edp->target, edp->label);
	sspn = splay_tree_lookup(gmln, (splay_tree_key) edp->source);
	printf("%p for %s\n", (void *)sspn, edp->source);
	if (!sspn) {
	    printf("node %s in edge %s to %s not defined\n", edp->source, edp->source, edp->target);
	    status = 1;
	    break;
	}
	sspn = splay_tree_lookup(gmln, (splay_tree_key) edp->target);
	printf("%p for %s\n", (void *)sspn, edp->source);
	if (!sspn) {
	    printf("node %s in edge %s to %s not defined\n", edp->target, edp->source, edp->target);
	    status = 1;
	    break;
	}
	/* translate the char * numbers into int */
	n = strtol((char *)edp->source, NULL, 10);
	/* improve this */
	edp->idsource = (int)n;
	n = strtol((char *)edp->target, NULL, 10);
	/* improve this */
	edp->idtarget = (int)n;
	nspn = splay_tree_successor(gmle, key);
    }

    /* stop at error */
    if (status) {
	return;
    }

    /* node and edges are checked, copy the data into the layouter
     * nodes and edges have uniq numbers starting at 1 in nodenum and edgenum
     * in hier.c:
     * add_new_node(struct gml_graph *g, struct gml_graph *ro, int nr, int foundid, char *nodename, char *nodelabel, int ncolor, int nbcolor, struct gml_rl *rlabel, struct gml_hl *hlabel, int fontcolor, int ishtml);
     * add_new_edge(struct gml_graph *g, struct gml_graph *ro, int foundsource, int foundtarget, char *elabel, int ecolor, int style, char *fcompass, char *tcompass, int constraint, int ishtml);
     */

    /* create the graph data rootgraph */
    maingraph = dp_calloc(1, sizeof(struct gml_graph));

    /* copy the node data */
    nspn = splay_tree_min(gmln);

    while (nspn) {
	key = nspn->key;
	ndp = (struct gmlnd *)nspn->value;
	/* node numbers start at 1 */
	maingraph->nodenum++;
	/* for gml tester no colors or dot specifics are needed */
	add_new_node(maingraph, NULL, maingraph->nodenum, (int)ndp->idlong, ndp->id, ndp->label, 0 /* ncolor */ , 0 /* nbcolor */ , NULL, NULL, 0, 0);
	nspn = splay_tree_successor(gmln, key);
    }

    /* copy the edge data */
    nspn = splay_tree_min(gmle);

    while (nspn) {
	key = nspn->key;
	edp = (struct gmled *)nspn->value;
	/* for gml tester no colors are needed */
	/* colors and dot specifics are skipped here. */
	add_new_edge(maingraph, NULL, edp->idsource, edp->idtarget, edp->label, 0, 0, NULL, NULL, 0, 0);
	nspn = splay_tree_successor(gmle, key);
    }

    return;
}

/* customized strdup() or use uniqstr() */
static char *gmlstrdup(const char *s)
{
    char *ret = NULL;
    char *s2 = NULL;
    size_t len = 0;
    s2 = (char *)s;
    if (s == NULL) {
	/* shouldnothappen */
	s2 = " ";
    }
    if (strlen(s) == 0) {
	/* shouldnothappen */
	s2 = " ";
    }
    len = strlen(s2);
    ret = dp_calloc(1, (len + 1));
    memmove(ret, s2, len);
    return (ret);
}

/* end. */
